Author Topic: stretched sprite as container -> not working  (Read 7555 times)

wouter

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
stretched sprite as container -> not working
« on: August 10, 2014, 06:24:42 AM »
-NGUIPanel(clipped)->sprite(with panel as container, stretched to 30% of x size of panel) -> label (that anchors to sprite, so that it shrinks allong with screen size etc)

I have an NGUI panel (clipped), then I have a sprite that uses that panel as an container, that sprite has a stretch component to it (say 0.3 of total x size), that I have a label that uses the sprite as an container.

This way I can have 3 labels next to eacht that each use 30% of the x size of the clipped panel (and shrink when it doesn't fit etc)

it all works.

The problem is that it only updates it positions etc after I resize the screen, initially its scaled wrongly, when resizing the window it jumps into its correct position.

Am I doing something wrong, should I go about this another way??

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: stretched sprite as container -> not working
« Reply #1 on: August 10, 2014, 05:46:13 PM »
Anchors have a setting on when they get updated. What did you set it to?

wouter

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
Re: stretched sprite as container -> not working
« Reply #2 on: August 11, 2014, 09:37:57 AM »
If i disable "run only once" it does work.. But is this a good solution?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: stretched sprite as container -> not working
« Reply #3 on: August 12, 2014, 03:56:07 AM »
It's fine, but... Question... why are you still using legacy anchoring / stretch? They were deprecated a very long time ago.

wouter

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
Re: stretched sprite as container -> not working
« Reply #4 on: August 15, 2014, 10:04:51 AM »
It's fine, but... Question... why are you still using legacy anchoring / stretch? They were deprecated a very long time ago.

ah did they? Well I don't know what else to use instead of them?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: stretched sprite as container -> not working
« Reply #5 on: August 16, 2014, 08:59:41 AM »
All widgets have built-in anchoring functionality.

wouter

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
Re: stretched sprite as container -> not working
« Reply #6 on: August 16, 2014, 12:47:59 PM »
All widgets have built-in anchoring functionality.

ah yes, but I do use that.
However that is not relative, say I anchor to the side of the screen, then I can say I want 200 to the right (but this is not reletive, on a smaller screen this is more).
However I cannot say anchor to the side of the screen, plus 10% of screen size to the right, that is the reason I use stretched sprite, since they are relative (and then I anchor widget and use the stretched one as a container).

If this is not the right way to do things, please let me know:)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: stretched sprite as container -> not working
« Reply #7 on: August 17, 2014, 08:48:53 AM »
Instead of choosing "left", "right" etc, choose "custom", and you can specify any relative value you like. 0 is left, 0.5 is center, 1 is right, etc. Check the documentation page for UIRect.