Support => NGUI 3 Support => Topic started by: erre on August 31, 2017, 03:14:19 AM
Title: Center Scroll View On Child
Post by: erre on August 31, 2017, 03:14:19 AM
Hi all,
I'm working using NGUI 3.11.4. I have a problem with CenterOnChild component. I've attached it to a grid (under a scroll view panel).
In Awake() I spawn my object list and call CenterOnChild.Recenter() that initialize the CenterOnChild component. In OnEnable() I refresh data in that page. After refresh I call CenterOn(myObjTransform).
The first time I enter in this page it doesn't work. After first time, everything works.
Is it the expected behaviour?
How can I fix this?
Thank you.
Best regards, Andrea.
Title: Re: Center Scroll View On Child
Post by: ArenMook on August 31, 2017, 10:27:28 AM
Awake() is a place to initialize only the local component. You should not be doing anything that relates to other components. Move it to Start(). I usually do this:
bool mStarted =false;
void DoStuff (){...}
void Start (){ mStarted =true; DoStuff();}
void OnEnable (){if(mStarted) DoStuff();}
Title: Re: Center Scroll View On Child
Post by: erre on August 31, 2017, 11:40:03 AM