Lifecycle overview
OnAwake
Called once, the first time the component becomes active. This happens during the
CallbackBatch that processes the component’s first enable — typically immediately after the containing scene tick starts or when the GameObject is first created in a running scene.Use OnAwake for one-time initialization that should happen before the component is enabled (caching references, creating objects, setting initial state).OnAwake is only called if ShouldExecute is true (see below). Interpolation is disabled during this call so that transform changes take effect immediately.OnEnabled
Called every time the component transitions from inactive to active — that includes immediately after
OnAwake on first enable, and again each time the component or any ancestor GameObject is re-enabled.OnStart
Called once immediately before the component’s first
OnUpdate (or OnFixedUpdate if that runs first). This lets you perform setup that requires all other components in the scene to have already run their OnAwake and OnEnabled.OnUpdate
Called every frame while the component is active.
Time.Delta is the time in seconds since the last frame.OnFixedUpdate
Called at a fixed interval tied to the physics tick rate (configured in Project Settings → Physics).
Time.Delta inside OnFixedUpdate is the fixed timestep, not the variable frame delta.Use OnFixedUpdate for anything that must stay in sync with physics: movement via Rigidbody, collision response, or deterministic simulation.OnPreRender
Called once per frame just before the scene is rendered. Not called on dedicated servers. Use this to update mesh bones, synchronize visual state, or push data to the render world.
OnDisabled
Called every time the component transitions from active to inactive — including when the GameObject is disabled, when the component’s
Enabled is set to false, and just before OnDestroy.OnDestroy
Called once when the component is permanently removed — either because
Destroy() was called on it, or because its parent GameObject was destroyed. After this call the component is no longer valid.After
OnDestroy, GameObject is set to null internally. Do not store references to the component after destruction — use IsValid() to guard any deferred callbacks.Additional callbacks
OnValidate
Called immediately after deserializing from JSON (scene or prefab load) and whenever a[Property] is changed in the editor inspector. Use it to clamp values, rebuild derived state, or log warnings when configuration is invalid.
OnRefresh
Called after the component’s state is updated from a network snapshot. Use it to react to authoritative values arriving from the host.OnParentChanged
Called when the component’s GameObject is re-parented. Both the old and new parent are provided.OnTagsChanged
Called when the GameObject’s tag set changes.The ShouldExecute rules
Not every component executes in every context. Before callingOnAwake, OnEnabled, OnUpdate, and OnFixedUpdate, the engine checks a private ShouldExecute gate:
| Condition | Result |
|---|---|
Scene is a PrefabCacheScene | Never executes |
Scene is null | Never executes |
Scene is an editor preview scene (IsEditor == true) and the component does not implement ExecuteInEditor | Never executes |
Application.IsDedicatedServer == true and the component implements DontExecuteOnServer | Never executes |
| All other cases | Executes normally |
Order summary
Components
How to create components, use [Property], and query the hierarchy
Scenes and GameObjects
The hierarchy that components live inside