- Home /
Difference between "lifetime of the script instance" and "lifetime of the behaviour"?
I've got a question regarding the following sentences taken from the Unity Script Reference:
"Awake is called only once during the lifetime of the script instance."
"Start is only called once in the lifetime of the behaviour."
I have a scene with an object that has a UnityScript which contains both (Awake and Start). This is a scene that the player will come back to, many times throughout the game.
From what the Script Reference says, I understand that the 1st time the scene loads, both functions are called and that from the 2nd time the scene loads and on, only function Start () is called again. Is it so? Thanks :)
Answer by DaveA · Jul 13, 2011 at 06:17 AM
I'm pretty sure they'd both be called each time, but you can always try it and see for yourself (post results here please). Just put in Debug.Log statements and see what happens.
I checked it (between 2 scenes that each loads the other one every 4") and it seems that both functions are called EACH TI$$anonymous$$$$anonymous$$ So I still don't understand the difference between "lifetime of the script instance" and "lifetime of the behaviour". (I modified the question's title because that's my problem actually - sorry about that)
It might be that it's different in the case where you can have some objects persist across scene loads? I doubt it.