Loads the Scene by its name or index in Build Settings.
Note: In most cases, to avoid pauses or performance hiccups while loading, you should use the asynchronous version of this command which is: LoadSceneAsync.
When using SceneManager.LoadScene, the loading does not happen immediately, it completes in the next frame. This semi-asynchronous behavior can cause frame stuttering and can be confusing because load does not complete immediately.
Since loading is set to complete in the next rendered frame, calling SceneManager.LoadScene forces all previous A Operations to complete, even if AsyncOperation.allowSceneActivation is set to false. This can be avoided by using LoadSceneAsync instead.
The given sceneName
can either be the Scene name only, without the .unity
extension, or the path as shown in the BuildSettings window still without the .unity
extension. If only the Scene name is given this will load the first Scene in the list that matches. If you have multiple Scenes with same name but different paths, you should use the full path.
Note that sceneName
is case insensitive, except when you load the Scene from an AssetBundle.
For opening Scenes in the Editor see EditorSceneManager.OpenScene. SceneA
can additively load SceneB
multiple times. The regular name is used for each loaded scene. If SceneA
loads SceneB
ten times each SceneB
with have the same name. Finding a particular added scene is not possible.