menu_bookDocumentation

Component Lifecycle Methods Reference

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

Component Lifecycle Methods

s&box Components have a well-defined lifecycle with specific methods you can override for different phases of initialization and updates.

Key Lifecycle Methods

MethodWhen CalledUse Case
OnLoad()After deserialization, asyncProcedural generation, asset loading during load screen
OnValidate()When properties change in editorEnforce property limits, validate data
OnAwake()Once when component createdOne-time initialization
OnStart()First time component enabledSetup that runs before first FixedUpdate
OnEnabled()When component becomes enabledSubscribe to events, start processes
OnUpdate()Every framePer-frame logic
OnPreRender()Every frame before renderingAnimation-dependent updates
OnFixedUpdate()Every fixed timestepPhysics, player movement
OnDisabled()When component disabledUnsubscribe, cleanup
OnDestroy()When component destroyedFinal cleanup

Example: Procedural Level Loading

CSHARP
public sealed class LevelGenerator : Component
{
    protected override async Task OnLoad()
    {
        LoadingScreen.Title = "Generating Level...";
        
        // Generate terrain
        await GenerateTerrain();
        
        // Place objects
        await PlaceObjects();
        
        LoadingScreen.Title = "Finalizing...";
        await Task.DelayRealtimeSeconds(0.5f);
    }
}

Important Notes

  • Component is only enabled if its GameObject and all ancestors are enabled
  • OnFixedUpdate is recommended for player movement to reduce trace count and avoid small-delta issues
  • OnPreRender is not called on dedicated servers
Was this helpful?