Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: AtomicBob on February 13, 2014, 01:50:36 PM

Title: 3.4.9 ScrollView Issues
Post by: AtomicBob on February 13, 2014, 01:50:36 PM
I dynamically populate a ScrollView at one point, and I noticed 2 oddities.

1) ResetPosition doesn't work if the object is disabled in the hierarchy. This is a problem for me since when I go to a new screen, I populate the ScrollView before I enabled the screen. I can work around this, but it'd be much more convenient to be able to reset scrolling position while the object is disabled.

2) In an attempt to work around 1) I noticed several methods throw exceptions if the ScrollView has never been enabled. For example, MoveAbsolute throws an exception because mTrans is null. MoveRelative throw one because panel is null.
Title: Re: 3.4.9 ScrollView Issues
Post by: ArenMook on February 14, 2014, 05:39:16 AM
Yeeeah... you should not work with something that has not even been started yet. The initialization happens in Awake(), which is the first thing executed as soon as the component has a chance to start up. Awake() is executed first -- before OnEnable() (and regardless of whether the component is enabled or not). In your case I am guessing the game object is disabled outright... so I strongly advise you to first enable it before working with its components.