Version: 5.4 beta (switch to 5.3)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

SceneManager

class in UnityEngine.SceneManagement

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

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Scene management at run-time.

Static Variables

sceneCountThe total number of scenes.
sceneCountInBuildSettingsNumber of scenes in Build Settings.

Static Functions

CreateSceneCreate an empty new scene with the given name additively.
GetActiveSceneGets the currently active scene.
GetSceneAtGet the scene at index in the SceneManager's list of added scenes.
GetSceneByNameSearches through the scenes added to the SceneManager for a scene with the given name.
GetSceneByPathSearches all scenes added to the SceneManager for a scene that has the given asset path.
LoadSceneLoads the scene by its name or index in Build Settings.
LoadSceneAsyncLoads the scene asynchronously in the background.
MergeScenesThis will merge the source scene into the destinationScene. This function merges the contents of the source scene into the destination scene, and deletes the source scene. All GameObjects at the root of the source scene are moved to the root of the destination scene. NOTE: This function is destructive: The source scene will be destroyed once the merge has been completed.
MoveGameObjectToSceneMove a GameObject from its current scene to a new scene. It is required that the GameObject is at the root of its current scene.
SetActiveSceneSet the scene to be active.
UnloadSceneUnloads all GameObjects associated with the given scene.

Events

activeSceneChangedAdd a delegate to this to get notifications when the active scene has changed.
sceneLoadedAdd a delegate to this to get notifications when a scene has loaded
sceneUnloadedAdd a delegate to this to get notifications when a scene has unloaded