class in UnityEngine.SceneManagement
/
Implemented in:UnityEngine.CoreModule
Suggest a change Success!Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Close Submission failedFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Close Your name Your email Suggestion* DescriptionManage scenes in the Player and in Play mode in the Editor.
You can use the SceneManager to manage and manipulate scenes in the Player.
Scene creation, loading and unloading
Accessing loaded scenes
The Scene Manager offers APIs to access currently loaded Scenes. For example, SceneManager.loadedSceneCount, SceneManager.GetSceneAt, and SceneManager.GetSceneByPath.
Scene manipulation
To move objects between scenes, use methods like SceneManager.MergeScenes and SceneManager.MoveGameObjectToScene.
SceneManager events
The SceneManager also exposes the following events:
Scripts can register on these events and then be notified when there are changes in the state of the SceneManager.
The scene list
The Player contains a BuildSettings object which records the list of scenes that are available to load. The contents of this list is exposed by SceneManager.sceneCountInBuildSettings and SceneUtility.GetScenePathByBuildIndex.
The contents of this list is determined when the Player is built:
The scene order is crucial for several reasons:
AssetBundles and Scenes
Scene management in the Editor
Notes
Additional resources: EditorSceneManager, SceneUtility, Scene.buildIndex, EditorBuildSettingsScene.enabled, AssetBundle.GetAllScenePaths.
Static Methods Method Description CreateScene Create an empty new Scene at runtime with the given name. GetActiveScene Gets the currently active Scene. GetSceneAt Get the Scene at index in the SceneManager's list of loaded Scenes. GetSceneByBuildIndex Get a Scene struct from a build index. GetSceneByName Searches through the Scenes loaded for a Scene with the given name. GetSceneByPath Searches all Scenes loaded for a Scene that has the given asset path. LoadScene Loads the Scene by its name or index in Build Settings. LoadSceneAsync Loads the Scene asynchronously in the background. MergeScenes This will merge the source Scene into the destinationScene. MoveGameObjectsToScene Move multiple GameObjects, represented by a NativeArray of instance IDs, from their current Scene to a new Scene. MoveGameObjectToScene Move a GameObject from its current Scene to a new Scene. SetActiveScene Set the Scene to be active. UnloadSceneAsync Destroys all GameObjects associated with the given Scene and removes the Scene from the SceneManager. Events Event Description activeSceneChanged Subscribe to this event to get notified when the active Scene has changed. sceneLoaded Assign a custom callback to this event to get notifications when a Scene has loaded. sceneUnloaded Add a delegate to this to get notifications when a Scene has unloaded.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4