menu_bookDocumentation
Scene.Load and Scene.LoadFromFile: Loading Scenes, DontDestroyOnLoad, and the Loading Sequence
Scene.Load and Scene.LoadFromFile: Loading Scenes Locally
Scene.Load loads a scene file into the current scene. This is a local-only operation — it does not bring other clients to the new scene. Use Game.ChangeScene for multiplayer scene changes.Loading a Scene
CSHARP
// Load by filename
Scene.LoadFromFile( "scenes/myscene.scene" );
// Load from a SceneFile resource
Scene.Load( mySceneFile );
// Load with options
var options = new SceneLoadOptions();
options.SetScene( "scenes/myscene.scene" );
options.IsAdditive = true; // don't clear existing objects
Scene.Load( options );SceneLoadOptions
| Property | Default | Description | |---|---|---| | IsAdditive | false | If true, don't clear existing objects before loading | | ShowLoadingScreen | true | Show the loading screen during load | | DeleteEverything | false | If false, objects with DontDestroyOnLoad survive | | IsSystemScene | false | Marks this as the system scene (loaded additively with every scene) |DontDestroyOnLoad
GameObjects with the DontDestroyOnLoad flag survive non-additive scene loads. They are moved to the scene root before the clear:CSHARP
myGameObject.Flags |= GameObjectFlags.DontDestroyOnLoad;Loading Sequence
- ISceneLoadingEvents.BeforeLoad fires
- Scene is cleared (unless additive)
- GameObjects are deserialized
- ISceneLoadingEvents.OnLoad tasks are awaited
- NavMesh is generated (if enabled)
- ISceneLoadingEvents.AfterLoad fires
- GameObjectSystem.Stage.SceneLoaded signal fires
- SceneNetworkSystem.OnLoadedScene is called (allows players to join)
System Scene
Every scene can have a "system scene" that is additively loaded alongside it. This is configured in project settings (SystemScene). Set WantsSystemScene = false on a scene to skip it (e.g., for menu scenes).
Was this helpful?