Control Script Execution Order via Attributes
When system initialization order matters (e.g., global singletons or managers executing before gameplay controllers), standard execution order can lead to race conditions.
The Tip: When system initialization order matters (e.g., global singletons or managers executing before gameplay controllers), standard execution order can lead to race conditions.
How to Use: Add [DefaultExecutionOrder(int order)] above class declarations. Negative integers force the script to execute prior to default components (0).
using UnityEngine;
[DefaultExecutionOrder(-100)]
public class GlobalGameManager : MonoBehaviour
{
private void Awake()
{
// Executes prior to default runtime scripts
}
}
Article complete?
20 XP lands automatically when you reach the end, and it counts toward today's quests.
Next level
Shader Graph Basics for 2D GamesGame Dev Articles · 1 min · +20 XPRate this article
Comments
Comments are held for moderation before appearing publicly.