SceneManagement

The SceneManagement system provides a dependency-aware scene loading framework built on top of Unity's SceneManager. Scenes are organized into a directed acyclic graph (SceneGraph) where each node declares its dependencies, enabling automatic loading of prerequisite scenes in the correct order.

Architecture

spinner

Dependency Loading Flow

spinner

Classes

Class
Description

Serializable scene reference with path, name, and GUID; implicit conversion to/from string and UnityScene

Graph node linking a Scene with its dependency list

ScriptableObject containing all SceneNode entries; provides add/remove/query operations

Static facade wrapping Unity's SceneManager with dependency chain resolution and async loading

Enums

Enum
Values
Description

LoadSceneMode

SINGLE, ADDITIVE

Maps to Unity's LoadSceneMode — controls whether existing scenes are unloaded

Quick Start

Define a Scene Graph (Editor)

Create a SceneGraph ScriptableObject asset. Add scenes via the editor or script:

Load a Scene with Dependencies

Listen for Scene Events

Implicit Conversions

Key Concepts

Dependency Chain Resolution

The SceneManager.GetDependencyChain() method performs an iterative depth-first search (DFS) to produce a topologically ordered list of scenes. Dependencies are loaded before the target scene, ensuring prerequisite scenes are available when the target scene initializes.

SceneGraph as Single Source of Truth

All scene lookups (GetScene, TryGetScene, implicit operators) resolve against the SceneGraph. At runtime, the SceneGraph is loaded from Resources. Every scene used by the game must exist in the graph, or load/unload callbacks will throw NotSupportedException.

Editor/Runtime Sync

The Scene class uses ISerializationCallbackReceiver to keep the SceneAsset reference (editor-only) synchronized with the serialized scenePath, sceneName, and guid fields that persist at runtime.

See Also

Last updated