Skip to main content
Scene inherits from GameObject, so it shares the component and hierarchy APIs. There is typically one active scene at a time, accessible via Game.ActiveScene.
// Access the active scene from anywhere
var scene = Game.ActiveScene;

// Iterate all active (non-editor) scenes
foreach (var s in Scene.All)
{
    Log.Info(s.Name);
}

Properties

IsEditor
bool
True when this scene is an editor scene rather than a runtime game scene. Components only execute in editor scenes if they implement ExecuteInEditor.
IsValid
bool
True if the scene has not been destroyed. Becomes false after Destroy() is called.
SceneWorld
SceneWorld
The underlying render world for this scene. Used by renderer components to register scene objects.
PhysicsWorld
PhysicsWorld
The physics world for this scene. Created lazily on first access with default gravity (Vector3.Down * 850) and continuous simulation.
// Read gravity
var gravity = Scene.PhysicsWorld.Gravity;
Directory
GameObjectDirectory
An index of every GameObject and Component in the scene. Used internally for fast lookups; prefer GetAllComponents<T>() for component queries.
RenderAttributes
RenderAttributes
Global render attributes shared by all renderable objects in this scene.
Volumes
VolumeSystem
A helper system for quickly finding components that have an associated volume shape.
Trace
SceneTrace
Entry point for scene-wide raycasts and shape-casts. Returns a builder you configure before calling Run() or RunAll().
var result = Scene.Trace
    .Ray(WorldPosition, WorldPosition + Vector3.Forward * 1000f)
    .WithoutTags("trigger")
    .Run();

if (result.Hit)
    Log.Info($"Hit {result.GameObject.Name} at {result.HitPosition}");
TimeScale
float
Multiplier applied to the scene’s time delta. Range [0, 1]. Set to 0 to pause, 1 for real-time.
Scene.TimeScale = 0.5f; // slow motion
IsFixedUpdate
bool
True while the scene is executing an OnFixedUpdate tick. Use this to distinguish fixed from variable update contexts.
FixedDelta
float
Time step of the current fixed update interval, in seconds. Mirrors Time.Delta inside OnFixedUpdate.
NetworkRate
float
Seconds between network update transmissions. Derived from ProjectSettings.Networking.UpdateRate.
WantsSystemScene
bool
When true, the system scene defined in project settings is additively loaded alongside this scene. Defaults to true. Set to false for menu or loading screens.

Static members

Scene.All
IEnumerable<Scene>
All active, non-editor scenes currently alive. Use this when you need to iterate over scenes in a multi-scene setup.
foreach (var scene in Scene.All)
{
    Log.Info(scene.Name);
}

Methods

CreateObject

public GameObject CreateObject(bool enabled = true)
Creates a new GameObject parented to this scene. Works even when this is not the active scene.
using (scene.Push())
{
    var go = scene.CreateObject();
    go.Name = "Spawned Object";
    go.AddComponent<ModelRenderer>();
}
Use scene.Push() to make a non-active scene the current active scene for the duration of an operation. This ensures components find the correct scene during construction.

Push

public IDisposable Push()
Makes this scene the active scene (Game.ActiveScene) for the duration of a using scope.
using (myScene.Push())
{
    // Game.ActiveScene == myScene here
    var go = new GameObject();
}

BatchGroup

public IDisposable BatchGroup()
Defers OnEnable, OnDisable, and NetworkSpawn callbacks until the scope ends. Ensures callbacks fire in a deterministic order when creating many objects at once.
using (Scene.BatchGroup())
{
    for (int i = 0; i < 100; i++)
    {
        var go = Scene.CreateObject();
        go.AddComponent<MyComponent>();
    }
}
// All OnEnabled callbacks fire here, in creation order

GetAllComponents

public IEnumerable<T> GetAllComponents<T>()
public IEnumerable<Component> GetAllComponents(Type type)
Returns all active components of type T across the entire scene. Supports interfaces as the type parameter.
foreach (var light in Scene.GetAllComponents<PointLight>())
{
    light.Enabled = false;
}
Only returns enabled and active components. Pass a Type overload if you need to query a type known only at runtime.

FindAllWithTag / FindAllWithTags

public IEnumerable<GameObject> FindAllWithTag(string tag)
public IEnumerable<GameObject> FindAllWithTags(IEnumerable<string> tags)
Searches every GameObject in the scene directory and yields those that match the given tag or all provided tags.
foreach (var enemy in Scene.FindAllWithTag("enemy"))
{
    enemy.Destroy();
}

FindInPhysics

public IEnumerable<GameObject> FindInPhysics(Sphere sphere)
public IEnumerable<GameObject> FindInPhysics(BBox box)
public IEnumerable<GameObject> FindInPhysics(Frustum frustum)
Returns all GameObjects whose physics shapes overlap the given volume.
var nearby = Scene.FindInPhysics(new Sphere(WorldPosition, 500f));
foreach (var go in nearby)
{
    Log.Info($"Found: {go.Name}");
}

Destroy

public override void Destroy()
Destroys the scene and all of its GameObjects, components, the PhysicsWorld, and the SceneWorld. Do not reference this scene after calling Destroy.

Tracing

Scene.Trace returns a SceneTrace builder. Chain filter methods then call Run() for the first hit or RunAll() for every hit.
var tr = Scene.Trace
    .Ray(from, to)
    .WithoutTags("player")
    .Run();

SceneTrace filter methods

MethodDescription
WithTag(string)Only hit objects that have this tag
WithAllTags(params string[])Only hit objects that have every tag
WithAnyTags(params string[])Only hit objects that have any of the tags
WithoutTags(params string[])Skip objects that have any of the tags
IgnoreGameObject(GameObject)Skip a specific object
IgnoreGameObjectHierarchy(GameObject)Skip an object and all its descendants
HitTriggers()Include trigger colliders
HitTriggersOnly()Hit only trigger colliders
IgnoreStatic()Skip static physics objects
IgnoreDynamic()Skip dynamic physics objects
UseHitboxes(bool)Include hitbox shapes

SceneTraceResult fields

Hit
bool
True if the trace intersected anything.
HitPosition
Vector3
World-space position of the intersection. Requires UseHitPosition() to be accurate.
Normal
Vector3
Surface normal at the hit point.
Fraction
float
How far along the trace [0..1] the hit occurred.
Distance
float
World-space distance between the start and end positions.
GameObject
GameObject
The GameObject that was hit, if any.
Component
Component
The Component that was hit, if any.
Surface
Surface
Physical surface properties of the hit material.

Networking

NetworkRate
float
Seconds between network snapshots. Set via ProjectSettings.Networking.UpdateRate.
IsBBoxVisibleToConnection(Connection, BBox)
bool
Returns true if the bounding box is within the PVS of the given connection. Used to gate object visibility.
IsPointVisibleToConnection(Connection, Vector3)
bool
Returns true if a world-space point is within the PVS of the given connection.

Build docs developers (and LLMs) love