- Home /
is there any function call will be call after i activate an object ?
i have a script attach to an object, after i deactivate the object the script will stop running too, is there any function will be called in the script after i activate the object again ?
the reason why i'm asking this is because i'm using "yield WaitForSeconds(1)", if i deactivate the object when it's still waiting, the script will stop running even if i active the object again.
Answer by Berenger · Feb 10, 2012 at 03:24 AM
That's because the coroutine need to be called again, if it's not one of unity like Start or Update. The callback for the activation is OnEnable.
I have a doubt though. I'm a little fuzzy between enabled/activate and OnEnable/Start. So if it's not one, it's the other !
just give it a tested, Start will only call once. if the object is not activate by default, OnEnable() and Start() both will be call. if Start() haven been called once, only OnEnable will call each time you activate the object. Thx!!!!!! =)
Just for completeness, OnDisable is called when the object is deactivated.