Author Topic: UIStretch widgets pop to size when activated the first time  (Read 2345 times)

andrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
UIStretch widgets pop to size when activated the first time
« on: February 13, 2013, 02:04:28 AM »
I have a number of UI widgets and panels that are inactive by default.  I've built the UI to the iphone5's aspect ratio and have UIStretch components on a number of the backgrounds and widgets to size them appropriately for iPad, etc.

The problem is, the first time these panels are made active and displayed, you can see them pop to their stretched positions.

I thought I could be clever and go in UIStretch.cs and add a PreStretch() function that calls Awake(), Start() and Update() once, but that doesn't work.  I think the first frame the NGUI render mesh is the original layout, and the next frame has the properly stretched layout.

Does anyone have a solution for this?  Thanks in advance.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIStretch widgets pop to size when activated the first time
« Reply #1 on: February 13, 2013, 01:43:00 PM »
Updating stretch isn't enough. You also have to force a refresh on the panel, or it will be delayed until the next frame.

andrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: UIStretch widgets pop to size when activated the first time
« Reply #2 on: February 13, 2013, 06:31:16 PM »
Refreshing the panels wasn't enough either.  I had to "PreAnchor" the anchors too... and it seems if you have widgets with UIStretch and UIAnchor on them they still can have issues.  This probably is never a problem if your panels/ui is active by default or offscreen, and it only happens the first time I activate those UI game objects.  thanks