Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facepunch/sbox-public/llms.txt
Use this file to discover all available pages before exploring further.
Scene is the top-level container for all GameObjects in s&box. It extends GameObject, so it shares the same hierarchy and component APIs, while adding scene-level concerns: loading from disk, finding objects and components across the entire hierarchy, physics world access, and scene events. This page documents the public API you interact with at runtime.
The active scene is always accessible via
Game.ActiveScene. Most of the time you get a Scene reference through Component.Scene or GameObject.Scene.Static members
All active, non-editor scenes currently loaded. Useful when running multiple additive scenes simultaneously.
Key properties
true when this is an editor scene (used for editing in the tooling, not for gameplay). Components with ExecuteInEditor still run; all others do not.true as long as the scene has not been destroyed. A destroyed scene has no SceneWorld.true while loading tasks registered by ISceneLoadingEvents.OnLoad are still pending. The loading screen remains visible while this is true.The
SceneFile resource this scene was last loaded from, or null if the scene was created in code.When
true (the default), the project’s system scene is additively loaded on top of this scene. Set to false for scenes that should not inherit system-scene content (e.g. bare menu scenes).The physics simulation for this scene. Lazily created on first access. Use it to configure gravity, run trace queries, and access physics bodies.
The render world associated with this scene. Renderable
SceneObjects (models, lights, etc.) are registered here.Global render attributes accessible by any renderable in this scene. Use to pass per-scene shader parameters.
Internal index of all
GameObjects and components in the scene. Prefer FindAllWithTag, GetAll<T>, and Get<T> over accessing this directly.A fast lookup system for components that implement a volume (bounding box). Use
Volumes.FindAll<T>(bounds) to query overlapping volumes efficiently.Constructor
SceneFile via Game.ChangeScene() or call Load() on the active scene.
Loading a scene
Load(GameResource)
SceneFile resource into this scene. Clears existing content unless the resource is an additive load.
A
SceneFile obtained from ResourceLibrary or a [Property] reference.Load(SceneLoadOptions)
SceneLoadOptions lets you configure additive loading, system scene suppression, and the loading screen.
LoadFromFile
Resource path, e.g.
"scenes/main.scene".Creating GameObjects
CreateObject
GameObject parented to this scene. This method pushes the scene as the active scene for the duration of construction, so components created inside the constructor target the correct scene even when called from an inactive scene context.
Whether the new object starts enabled.
Finding GameObjects and components
GetAll<T>
T. Works for components, interfaces, and GameObjectSystem subtypes. The results come from a fast type-indexed cache — this is the preferred way to iterate over all components of a given type.
Get<T>
T in the scene, or default when none is found. Useful for singletons and global systems.
FindAllWithTag
GameObjects in the scene that have the given tag (including inherited tags from ancestors).
FindAllWithTags
GameObjects that have all of the specified tags.
Scene events
RunEvent<T>
action on every enabled object in the scene that implements interface T. Uses the fast type index — preferred over iterating GetAll<T>() manually.
ISceneEvent<T>
ISceneEvent<T> provides static helper methods so your event interface can post to the entire scene without needing a direct Scene reference.
Broadcasts the event to the entire active scene.
Broadcasts the event to a specific
GameObject and optionally its descendants.Batching
BatchGroup
OnEnabled/OnDisabled callbacks and network spawn messages created inside the scope and dispatches them in a deterministic order when the scope is disposed. Use when spawning multiple objects at once to ensure they can find each other during OnAwake/OnEnabled.
Push
Game.ActiveScene for the duration of the scope. Automatically restored when the scope is disposed. Used internally by many engine methods.
Lifecycle
Destroy
GameObjects and components, deletes the PhysicsWorld and SceneWorld, and removes the scene from Scene.All. After this call, IsValid is false. Do not use the scene reference after calling Destroy().
Loading screen and tasks
When a scene loads, registeredISceneLoadingEvents.OnLoad handlers can return a Task to keep the loading screen visible until async work completes (e.g. generating a NavMesh, downloading content).
true while loading tasks are still pending.Begins the loading task tracking loop. Called automatically when
Load() is invoked outside of the editor.See also
GameObject
The fundamental scene object that components attach to.
Component
The base class for all game scripts.
Physics
Guide to using
PhysicsWorld, traces, and rigidbodies.