s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationSceneComponentsComponent Methods
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Scene
Scene

Component Methods

When creating a component there are a number of methods you can override and implement.

:::info Note that for the component be enabled, its GameObject and all of their ancestors need to be enabled too. The GameObject will be considered disabled if one of its ancestor GameObjects is not enabled.

:::

This is called after deserialization and is meant for a place for the component to "load". When loading a scene, the loading screen will stay open and the game won't start until all components OnLoad tasks are complete.

Unlike other methods (except OnDestroy), this one will execute even if the component is inactive. You may need to check Component.Active if you don't want the OnLoad to execute on inactive components.

If your component is doing something special, such as generating a procedural level, you can override this on your component to do this in the loadscreen.

protected override async Task OnLoad()
{
	LoadingScreen.Title = "Loading Something..";
	await Task.DelayRealtimeSeconds( 1.0f );
}

There's also an overload that gives you a LoadingContext, so you can title your own task instead of stomping the whole loading screen.

protected override async Task OnLoad( LoadingContext context )
{
	context.Title = "Generating Level..";
	await Task.DelayRealtimeSeconds( 1.0f );
}

:::info Internally this is where the Map component downloads and loads the map.

:::

Called once when the component is created, but only if our parent GameObject is enabled. This is called after deserialization and loading.

Called when the component is enabled for the first time. Should always get called before the first OnFixedUpdate.

Called when the component is enabled.

Called every frame.

:::info This method is not called on dedicated servers.

:::

Called every frame, right before rendering is about to take place.

This is called after animation bones have been calculated, so it usually a good place to do things that count on that.

Called every fixed timestep.

In general, it's wise to use a fixed update for things like player movement (the built in Character Controller does this). This reduces the amount of traces a client is doing every frame, and if your client is too performant, the move deltas per frame can be so small that they create problems.

Called when the component is disabled.

Called when the component is destroyed. This method will be called even if the component was never enabled.

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2026-08-03. Read it rendered on the official docs.

More in Scene

Advanced Topics
Async
Camera Effects
Component Interfaces
Component Versioning
Components
Events
Execution Order
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.