Author Topic: Anchors on scaled onbjects  (Read 6117 times)

PauliusLiekis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Anchors on scaled onbjects
« on: October 13, 2015, 04:08:51 AM »
Hi,

It looks like anchors do not work correctly on scaled objects. For example if my object has scale and I set it to anchor on left=0 if won't match to the left of the target object.

Is there a workaround for that?

Thanks,
Paulius
« Last Edit: October 13, 2015, 04:15:38 AM by PauliusLiekis »

tydygunn

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: Anchors on scaled onbjects
« Reply #1 on: October 13, 2015, 01:46:14 PM »
Everything in your UI's hierarchy (aside from the UI Root object itself) should be a scale of 1. Every parent, panel, widget, and sprite all set to 1. It's a little more work but it keeps everything looking crisp and keeps the colliders and anchors playing nice.

At the bare minimum, you should at least make sure it's scaled uniformly (i.e. - (1.24, 1.24, 1.24) instead of (1.56, 1.24, 1)).

I know it doesn't answer your question, sorry. That's the long and short of it though.

PauliusLiekis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Anchors on scaled onbjects
« Reply #2 on: October 13, 2015, 02:48:25 PM »
Well...I wish I could do it that way. Problem is with font resolutions. If your UIRoot.ContentHeight is much smaller than screen height, then all your font will look blurry. A workaround for that is to increase font size and decrease scale on these objects (i.e. double font size, set scale to 0.5), but problem is that then anchors do not work.

So I was wondering how people deal with that.

tydygunn

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: Anchors on scaled onbjects
« Reply #3 on: October 13, 2015, 03:07:13 PM »
Gotcha! What I do for that is I'll set the "Keep Crisp" option on each label to "Never" and then I change the fonts size for each label individually. They're usually set to 24, 54, 72, and 96 for me to keep the label sizes consistent (obviously you'd have your own font sizes, those are just the ones that work for my projects). It's that "Keep Crisp" option that blurs everything when screen sizes change.

You can change all the fonts in a scene at once by typing "t:UILabel" in your Hierarchy search bar and then select all entries.

That's what I do anyways. Aren might have other suggestions.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anchors on scaled onbjects
« Reply #4 on: October 14, 2015, 08:41:14 AM »
Technically the "Keep Crisp" option keeps the fonts crisp (only with dynamic fonts). It works by using actual pixel size. If the UIRoot gets set to manual and become, say, half the screen size, then your font size will be doubled to compensate, ensuring that it remains crisp.

You can try it by making a new scene, setting the Game View to use a fixed size (say 1280x720), adding a dynamic font-using label set to Keep Crisp, then altering the UIRoot's content height. For example, change it to 360 and hit Play -- your label will become crisp. This is because its font will be effectively doubled in density to keep it crisp.