Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Wisteso on May 12, 2015, 12:01:41 PM

Title: ResetPosition on UIScrollView not working before anchors have equalized
Post by: Wisteso on May 12, 2015, 12:01:41 PM
This is a (very delayed) followup from http://www.tasharen.com/forum/index.php?topic=9751 but since that topic kind of went on a different tangent, I'm creating a separate post.

TL;DR is...


I've tried running UpdateAnchors, Refresh, and a few other things immediately before calling ResetPosition but no luck. I was nesting some anchors, but now have most anchors working off of UIRoot (when possible) rather than having a small anchor decency chain.

If I run ResetPosition() after 0.25 seconds instead of immediately after enabling the GUI area, it also works but looks hacky. Pretty sure the issue is that the anchors need to be refreshed before calling ResetPosition but I want to leave these areas disabled when not being used, for performance reasons.
Title: Re: ResetPosition on UIScrollView not working before anchors have equalized
Post by: Wisteso on May 12, 2015, 02:03:40 PM
Did some debugging / experimenting with the UIPanel and found out that indeed, the issue was due to OnAnchor being executed (for the first time) after ResetPosition was called (for the first time). OnAnchor is run as part of Update() on the UIPanel, so I just replaced the call to UIPanel.Refresh() with a call to UIPanel.Update() instead and viola. Issue solved.

obj.GetComponent<UIPanel>().Update();
obj.GetComponent<UIScrollView>().ResetPosition();