Hello!
Long time no see In the UIToggle script, whenever the GameObject containing the UIToggle is activated for the first time, it will directly send the onToggleChange event, even if we did not click on the toggle.
This is great for some purpose, so that you can initialize your UI directly depending on the state etc...
But imagine that you're doing complex operations when you change a toggle, and you do not want anything to be done at Start. You only want to activate something when the user click on a toggle, not when the toggle become visible... there is no way to do that.
Well yes, I could in my own onToggleChange callback, do a boolean check to see if it's the first time it's going in this method, but if I have 50 toggles, I need 50 different booleans to manage that...
The only option I found, is to modify the UIToggle script, just doing this in the Set() method:
if (EventDelegate.IsValid(onChange))
{
if (!m_isFirstTimeSendingEvent)
{
EventDelegate.Execute(onChange);
}
m_isFirstTimeSendingEvent = false;
}
The thing is, next time I update NGUI... my code will be removed.
Do you have a solution for this?
Thanks!