menu_bookDocumentation

Component execution order — OnAwake, OnStart, OnUpdate, OnFixedUpdate, and OnLateUpdate

calendar_today May 5, 2026 schedule ~1 min read person patrickjr verified 50

Component Execution Order

s&box calls component lifecycle methods in a defined order each frame. Understanding this order is essential for avoiding race conditions between components.

Key Rule

Do not rely on the order in which the same callback runs across different GameObjects. If you need guaranteed ordering between components, use a GameObjectSystem with explicit stage registration instead.

Lifecycle Methods

MethodWhen it runs
OnAwake()Once, when the component is first created — before the scene is fully ready
OnStart()Once, on the first frame the component is active — after all OnAwake calls
OnEnabled()Every time the component is enabled (including the first time)
OnUpdate()Every frame while the component is active
OnFixedUpdate()Every physics tick (fixed timestep)
OnLateUpdate()After all OnUpdate calls — good for camera follow
OnPreRender()Just before rendering — use for last-minute transform adjustments
OnDisabled()Every time the component is disabled
OnDestroy()Once, when the component is destroyed

Frame Flow (Simplified)

CODE
OnAwake  (new components)
OnStart  (new components, first frame only)
OnEnabled (newly enabled components)
  ↓
OnFixedUpdate  (0 or more times, physics timestep)
  ↓
OnUpdate  (all active components)
  ↓
OnLateUpdate  (all active components)
  ↓
OnPreRender
  ↓
Render

Practical Patterns

CSHARP
public sealed class MyComponent : Component
{
    // Use OnStart (not OnAwake) to access other components —
    // they're guaranteed to exist by then
    protected override void OnStart()
    {
        var rb = Components.Get<Rigidbody>();
    }

    // Use OnFixedUpdate for physics — consistent timestep
    protected override void OnFixedUpdate()
    {
        // Time.Delta here is the fixed physics delta
    }

    // Use OnLateUpdate for camera — runs after all movement
    protected override void OnLateUpdate()
    {
        CameraGo.WorldPosition = WorldPosition + offset;
    }

    // Always unsubscribe events in OnDisabled/OnDestroy
    protected override void OnEnabled()  => SomeEvent += Handler;
    protected override void OnDisabled() => SomeEvent -= Handler;
}

Cross-Component Ordering

If component A must run before component B, use GameObjectSystem with explicit order values rather than relying on component creation order.

Was this helpful?