Author Topic: Widgets Relative Size  (Read 5449 times)

Dima

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Widgets Relative Size
« on: March 12, 2014, 08:19:41 AM »
Hello there!

I've been using NGUI for a while now but there are some things I just don't understand.
The most important is the fact that some widgets can't be set with a relative size (eg.: Label width, Panel).

Is there some informations I am missing ?

My issue, in other words, is if I set my UILabel width, it won't scale from a resolution to another. It will just stick to the pixels I have set. If I want it to be relative, do I have to code it myself or is there a method I didn't see in NGUI ?

Thank you,
Dima.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widgets Relative Size
« Reply #1 on: March 12, 2014, 06:33:20 PM »
To set relative size you need to use anchors: http://www.tasharen.com/forum/index.php?topic=7013.0

Turn on anchoring, set what it should be relative to, and then choose how it should be relative. To get percent-based movement, use Custom anchoring as mentioned in the documentation I linked above.

Dima

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Widgets Relative Size
« Reply #2 on: March 13, 2014, 05:35:30 PM »
Hey,

Well I didn't update NGUI to 3.X yet. That is why I can't use Anchor to stretch my label width automatically (but I can position them).
The update is scheduled but didn't get enough time to make the changes to our current project. Sorry that I asked a question about an issue you solved with an update.

Seems new UIAnchor can position widget's bounds relatively to other widgets, thus stretching automatically the anchored widget. Fantastic.

Thank you