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.
Properties
True when this scene is an editor scene rather than a runtime game scene. Components only execute in editor scenes if they implement
ExecuteInEditor.True if the scene has not been destroyed. Becomes false after
Destroy() is called.The underlying render world for this scene. Used by renderer components to register scene objects.
The physics world for this scene. Created lazily on first access with default gravity (
Vector3.Down * 850) and continuous simulation.An index of every
GameObject and Component in the scene. Used internally for fast lookups; prefer GetAllComponents<T>() for component queries.Global render attributes shared by all renderable objects in this scene.
A helper system for quickly finding components that have an associated volume shape.
Entry point for scene-wide raycasts and shape-casts. Returns a builder you configure before calling
Run() or RunAll().Multiplier applied to the scene’s time delta. Range
[0, 1]. Set to 0 to pause, 1 for real-time.True while the scene is executing an
OnFixedUpdate tick. Use this to distinguish fixed from variable update contexts.Time step of the current fixed update interval, in seconds. Mirrors
Time.Delta inside OnFixedUpdate.Seconds between network update transmissions. Derived from
ProjectSettings.Networking.UpdateRate.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
All active, non-editor scenes currently alive. Use this when you need to iterate over scenes in a multi-scene setup.
Methods
CreateObject
GameObject parented to this scene. Works even when this is not the active scene.
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
Game.ActiveScene) for the duration of a using scope.
BatchGroup
OnEnable, OnDisable, and NetworkSpawn callbacks until the scope ends. Ensures callbacks fire in a deterministic order when creating many objects at once.
GetAllComponents
T across the entire scene. Supports interfaces as the type parameter.
FindAllWithTag / FindAllWithTags
GameObject in the scene directory and yields those that match the given tag or all provided tags.
FindInPhysics
GameObjects whose physics shapes overlap the given volume.
Destroy
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.
- Ray
- Sphere cast
- Box cast
- RunAll
SceneTrace filter methods
| Method | Description |
|---|---|
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
True if the trace intersected anything.
World-space position of the intersection. Requires
UseHitPosition() to be accurate.Surface normal at the hit point.
How far along the trace [0..1] the hit occurred.
World-space distance between the start and end positions.
The
GameObject that was hit, if any.The
Component that was hit, if any.Physical surface properties of the hit material.
Networking
Seconds between network snapshots. Set via
ProjectSettings.Networking.UpdateRate.Returns true if the bounding box is within the PVS of the given connection. Used to gate object visibility.
Returns true if a world-space point is within the PVS of the given connection.