Order of Events for the Script Lifecycle in Unity 2021

Per Unity: https://docs.unity3d.com/Manual/ExecutionOrder.html

The Script lifecycle flowchart will be broken down in this article.
Above we can see the order of event for initialization events.

Awake > OnEnable > Reset > Start

It’s easy to run into issues if we try to do something in an earlier event for something created in a later event.

If we attempt to call from Awake() a game object that is not created until the Start() event, we will get an error because the game object does not yet exist!

Moving down the flowchart, I just want to highlight that the FixedUpdate() event occurs before the Update() event during Physics execution.

Note that OnDrawGizmos() event occurs after the Update() event.

In our last section of the flowchart, we can see that OnGUI() event occurs right after OnDrawGizmos().

I’d also like to point out the Decommissioning section where OnApplicationQuit() event occurs before OnDisable() event which occurs before OnDestroy() event.

Please see the link to the Unity documentation at the beginning of this article for a more verbose description of this chart for these events.

https://docs.unity3d.com/uploads/Main/monobehaviour_flowchart.svg

For the complete, unadulterated version of the flowchart, please see the link above.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store