0
0
Unityframework~5 mins

Awake vs Start execution order in Unity

Choose your learning style9 modes available
Introduction

Awake and Start are special methods in Unity that help set up your game objects. Knowing their order helps you control when things happen in your game.

When you want to initialize variables or references before the game starts running.
When you need to set up connections between game objects before any gameplay begins.
When you want to delay some setup until just before the first frame updates.
When you want to make sure some code runs only once at the very start of the game.
Syntax
Unity
void Awake() {
    // Initialization code here
}

void Start() {
    // Code to run before first frame update
}

Awake runs first on enabled scripts.

Start runs after Awake and only if the script is enabled.

Examples
This example shows Awake running before Start.
Unity
void Awake() {
    Debug.Log("Awake called");
}

void Start() {
    Debug.Log("Start called");
}
Awake sets a value, Start uses it.
Unity
void Awake() {
    playerHealth = 100;
}

void Start() {
    Debug.Log($"Player health is {playerHealth}");
}
Sample Program

This Unity script prints messages to show the order of Awake and Start methods.

Unity
using UnityEngine;

public class ExecutionOrderExample : MonoBehaviour {
    void Awake() {
        Debug.Log("Awake called");
    }

    void Start() {
        Debug.Log("Start called");
    }
}
OutputSuccess
Important Notes

Awake is used for setup that must happen before anything else.

Start is good for things that depend on other objects being ready.

If a script is disabled at initialization, Awake still runs. Start runs when the script is first enabled.

Summary

Awake runs first, used for early setup.

Start runs after Awake, used for setup before gameplay.

Understanding their order helps avoid bugs and timing issues.