Awake function calling order logic

I wonder in what order the different objects’ Awake functions are called. To test it i created 8 object in a scene. Each object has a script which simply run below code in Awake function.

print(gameObject.name + " in awake")

That’s the result:


I couldn’t figure out in what order unity call awake function.

Can someone enlighten me ?

As per the docs, order is not guaranteed. In my observation it is often deceptively stable running in the editor, and if you make something that relies on it, it will likely fail in the build, even sometimes only on one platform.

Here is some timing diagram help:

For completeness I mention that you can change the priority of your scripts but since that lives outside of your visible codebase, I DO NOT RECOMMEND using that feature.

https://docs.unity3d.com/Manual/class-MonoManager.html

1 Like

Thanks for the clear answer