Author Topic: How to disable/handle callback value changes on startup?  (Read 4735 times)

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
How to disable/handle callback value changes on startup?
« 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?
« Last Edit: July 05, 2015, 04:41:12 AM by Shifty Geezer »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to disable/handle callback value changes on startup?
« Reply #1 on: July 06, 2015, 08:05:34 PM »
Set the delegate in Start() in a script set to execute after everything else.

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: How to disable/handle callback value changes on startup?
« Reply #2 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);
}