Author Topic: Sometimes widgets don't render after legacy animation.  (Read 3775 times)

Tiktaalik

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 39
    • View Profile
Sometimes widgets don't render after legacy animation.
« on: August 21, 2014, 01:12:39 PM »
Preamble: I have a fix for this problem but I wanted to make a post about it to find out more about how NGUI works and to provide a solution in case anyone else ever comes across this same issue.

I found a weird problem when running our game on old slow iPhones (3GS and 4). In situations where we activate an UIPanel and then perform a legacy animation on it, we arrive at a situation where the widgets on the panel aren't visible, but when you click on the space where they should be, they blink into existence. It is like they are actually there, but they have not been drawn. If you zoom out however, you can see that the widgets are actually remaining in their original, pre-animation positions. Very odd. Since we didn't see the animation play, we suspect what is happening is that the activation of the Panel and all its widgets is taking so long that the animation is actually completed before the widgets were active. Somehow after this the widgets are in some weird state that I don't fully understand.

I thought I'd be able to fix this by forcing a UIPanel.Refresh(), but that didn't work. I was able to fix it however with this following code:

 
  1. foreach(var w in m_uiPanel.widgets){
  2.     w.MarkAsChanged();
  3. }
  4.  
  5. m_uiPanel.Refresh();
  6.  

In this thread you mentioned that

Quote
Panel's Refresh() will refresh the draw calls, but only of the widgets that have been registered with the panel. MarkAsChanged registers the widget with the panel.

Are the widgets being unregistered somehow? Or is it that some other code that is supposed to mark widgets as changed never runs in this case? I'm not really sure why I have to manually mark all the widgets as changed.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sometimes widgets don't render after legacy animation.
« Reply #1 on: August 22, 2014, 03:46:14 AM »
If you enable a game object with a widget on it, then immediately change its position, its position change may not be noticed correctly. For this reason it's best to move first, then enable. I vaguely remember investigating it a couple of days ago and adding an additional check around this that may or may not address it in the next update...