Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Shifty Geezer on July 04, 2015, 01:00:17 PM

Title: How to disable/handle callback value changes on startup?
Post by: Shifty Geezer on July 04, 2015, 01:00:17 PM
I have a toggle that sets a value for my camera type. It uses the UIToggle's 'OnValueChange' delegate. The problem is this is called when the level starts as values are disabled/enabled, I guess. The same happens with tweens getting callbacks at start.

Is there a way to not call the delegate on initialisation somehow? Or is there a correct approach to deal with this problem?
Title: Re: How to disable/handle callback value changes on startup?
Post by: ArenMook on July 06, 2015, 08:05:34 PM
Set the delegate in Start() in a script set to execute after everything else.
Title: Re: How to disable/handle callback value changes on startup?
Post by: Shifty Geezer on July 07, 2015, 07:53:52 AM
Thanks. For reference, instead of adding UI_Control/SavePrefs in the object's Inspector, I use:
Quote
Start(){
   optionsTweenAlpha.AddOnFinished(SavePrefs);
}