- Home /
Why the OnApplicationPause() calls before to Awake() in a same class?
I have the methods OnApplicationPause and Awake in a function, but the onapplicationpause is call before to awake, in my game, no happened that before, in Unity 3.5, just started to exectute like that in unity 4. any idea?
Thanks for your help
According to the documentation... Awake() should be called first. How did you check that OnApplicationPause() was called before Awake()?
Edit : I tried on my side, and Awake() is called first. :/
Answer by DavidDebnar · Jul 09, 2013 at 07:41 PM
FALSE! Awake is called first, infact, it actually picks up the time from the previous run, because Time.realtimeSinceStartup is initialized after Awake (the time from the last run). OnApplicationPause logs 0.0000124 - after Awake.
function OnApplicationPause () {
Debug.Log("OAP: " + Time.realtimeSinceStartup.ToString());
}
function Awake () {
Debug.Log("Awake: " + Time.realtimeSinceStartup.ToString());
}
--David--
Just because it's supposed to be called first doesn't mean that he hasn't done something to mess with the order of his code. He may have called OnApplicationPause in his Awake function.
...Then in this case Awake() is called before OnApplicationPause() ^^