0
0
Unityframework~10 mins

MonoBehaviour lifecycle in Unity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - MonoBehaviour lifecycle
Game Start
Awake() called
OnEnable() called
Start() called
Update() called every frame
FixedUpdate() called every physics step
LateUpdate() called every frame after Update
OnDisable() called
OnDestroy() called
Game End
This flow shows the order in which Unity calls MonoBehaviour lifecycle methods from game start to end.
Execution Sample
Unity
void Awake() { Debug.Log("Awake called"); }
void Start() { Debug.Log("Start called"); }
void Update() { Debug.Log("Update called"); }
This code logs messages when Awake, Start, and Update methods are called during the game lifecycle.
Execution Table
StepMethod CalledWhen CalledActionOutput
1Awake()When script instance is loadedInitialize variablesLogs: Awake called
2OnEnable()When object becomes activePrepare objectNo output in sample
3Start()Before first frame updateSetup before gameplayLogs: Start called
4Update()Every frameGame logic updateLogs: Update called
5FixedUpdate()Every physics stepPhysics calculationsNo output in sample
6LateUpdate()Every frame after UpdateFollow-up logicNo output in sample
7OnDisable()When object becomes inactiveCleanup or pauseNo output in sample
8OnDestroy()When object is destroyedFinal cleanupNo output in sample
9EndGame ends or object destroyedStop lifecycleNo further calls
💡 Lifecycle ends when object is destroyed or game stops.
Variable Tracker
VariableStartAfter AwakeAfter OnEnableAfter StartAfter UpdateAfter OnDisableAfter OnDestroy
isActivefalsefalsetruetruetruefalsefalse
initializedfalsetruetruetruetruetruefalse
Key Moments - 3 Insights
Why is Awake called before Start?
Awake is called when the script instance loads to initialize variables early, while Start is called just before the first frame to set up gameplay. See execution_table rows 1 and 3.
Why does Update run many times but Awake only once?
Update runs every frame to keep game logic updated, but Awake runs only once to initialize. See execution_table rows 1 and 4.
What happens when the object is disabled?
OnDisable is called to pause or clean up before the object becomes inactive. See execution_table row 7 and variable_tracker for isActive changes.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step is the object considered active?
AStep 7 OnDisable()
BStep 2 OnEnable()
CStep 1 Awake()
DStep 8 OnDestroy()
💡 Hint
Check variable_tracker column After OnEnable where isActive changes to true.
According to the execution_table, which method runs every frame during gameplay?
AStart()
BAwake()
CUpdate()
DOnDisable()
💡 Hint
Look at Step 4 in execution_table where Update() is called every frame.
If the object is destroyed, which method is called last according to the lifecycle?
AOnDestroy()
BOnDisable()
CStart()
DAwake()
💡 Hint
See execution_table Step 8 for OnDestroy() called when object is destroyed.
Concept Snapshot
MonoBehaviour lifecycle methods run in this order:
Awake() -> OnEnable() -> Start() -> Update() (every frame) -> FixedUpdate() (physics) -> LateUpdate() -> OnDisable() -> OnDestroy()
Awake initializes early, Start runs before first frame, Update runs every frame.
OnDisable and OnDestroy handle cleanup.
This order controls script behavior during game play.
Full Transcript
The MonoBehaviour lifecycle in Unity starts with Awake, which initializes the script instance when loaded. Then OnEnable is called when the object becomes active. Start runs before the first frame update to prepare gameplay. Update runs every frame to handle game logic. FixedUpdate runs every physics step for physics calculations. LateUpdate runs after Update for follow-up logic. When the object is disabled, OnDisable is called to pause or clean up. Finally, OnDestroy is called when the object is destroyed for final cleanup. Variables like isActive track if the object is active, changing after OnEnable and OnDisable. This lifecycle ensures scripts run in the correct order during the game.