C# Класс UnityEngine.SceneManagement.SceneManager

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
CreateScene ( string sceneName ) : Scene

Create an empty new scene at runtime with the given name.

GetActiveScene ( ) : Scene

Gets the currently active scene.

GetSceneAt ( int index ) : Scene

Get the scene at index in the SceneManager's list of added scenes.

GetSceneByBuildIndex ( int buildIndex ) : Scene

Get a scene struct from a build index.

GetSceneByName ( string name ) : Scene

Searches through the scenes added to the SceneManager for a scene with the given name.

GetSceneByPath ( string scenePath ) : Scene

Searches all scenes added to the SceneManager for a scene that has the given asset path.

LoadScene ( int sceneBuildIndex, [ mode ) : void

Loads the scene by its name or index in Build Settings.

LoadScene ( string sceneName, [ mode ) : void

Loads the scene by its name or index in Build Settings.

LoadSceneAsync ( int sceneBuildIndex, [ mode ) : AsyncOperation

Loads the scene asynchronously in the background.

LoadSceneAsync ( string sceneName, [ mode ) : AsyncOperation

Loads the scene asynchronously in the background.

MergeScenes ( Scene sourceScene, Scene destinationScene ) : void

This 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.

MoveGameObjectToScene ( GameObject go, Scene scene ) : void

Move a GameObject from its current scene to a new Scene. You can only move root GameObjects from one Scene to another. This means the GameObject to move must not be a child of any other GameObject in its Scene.

SetActiveScene ( Scene scene ) : bool

Set the scene to be active.

UnloadSceneAsync ( Scene scene ) : AsyncOperation

Destroyes all GameObjects associated with the given scene and removes the scene from the SceneManager.

UnloadSceneAsync ( int sceneBuildIndex ) : AsyncOperation

Destroyes all GameObjects associated with the given scene and removes the scene from the SceneManager.

UnloadSceneAsync ( string sceneName ) : AsyncOperation

Destroyes all GameObjects associated with the given scene and removes the scene from the SceneManager.

Приватные методы

Метод Описание
GetAllScenes ( ) : UnityEngine.SceneManagement.Scene[]
INTERNAL_CALL_CreateScene ( string sceneName, Scene &value ) : void
INTERNAL_CALL_GetActiveScene ( Scene &value ) : void
INTERNAL_CALL_GetSceneAt ( int index, Scene &value ) : void
INTERNAL_CALL_GetSceneByBuildIndex ( int buildIndex, Scene &value ) : void
INTERNAL_CALL_GetSceneByName ( string name, Scene &value ) : void
INTERNAL_CALL_GetSceneByPath ( string scenePath, Scene &value ) : void
INTERNAL_CALL_MergeScenes ( Scene &sourceScene, Scene &destinationScene ) : void
INTERNAL_CALL_MoveGameObjectToScene ( GameObject go, Scene &scene ) : void
INTERNAL_CALL_SetActiveScene ( Scene &scene ) : bool
Internal_ActiveSceneChanged ( Scene previousActiveScene, Scene newActiveScene ) : void
Internal_SceneLoaded ( Scene scene, LoadSceneMode mode ) : void
Internal_SceneUnloaded ( Scene scene ) : void
LoadScene ( int sceneBuildIndex ) : void
LoadScene ( string sceneName ) : void
LoadSceneAsync ( int sceneBuildIndex ) : AsyncOperation
LoadSceneAsync ( string sceneName ) : AsyncOperation
LoadSceneAsyncNameIndexInternal ( string sceneName, int sceneBuildIndex, bool isAdditive, bool mustCompleteNextFrame ) : AsyncOperation
UnloadScene ( Scene scene ) : bool
UnloadScene ( int sceneBuildIndex ) : bool
UnloadScene ( string sceneName ) : bool
UnloadSceneNameIndexInternal ( string sceneName, int sceneBuildIndex, bool immediately, bool &outSuccess ) : AsyncOperation

Описание методов

CreateScene() публичный статический метод

Create an empty new scene at runtime with the given name.

public static CreateScene ( string sceneName ) : Scene
sceneName string The name of the new scene. It cannot be empty or null, or same as the name of the existing scenes.
Результат Scene

GetActiveScene() публичный статический метод

Gets the currently active scene.

public static GetActiveScene ( ) : Scene
Результат Scene

GetSceneAt() публичный статический метод

Get the scene at index in the SceneManager's list of added scenes.

public static GetSceneAt ( int index ) : Scene
index int Index of the scene to get. Index must be greater than or equal to 0 and less than SceneManager.sceneCount.
Результат Scene

GetSceneByBuildIndex() публичный статический метод

Get a scene struct from a build index.

public static GetSceneByBuildIndex ( int buildIndex ) : Scene
buildIndex int Build index as shown in the Build Settings window.
Результат Scene

GetSceneByName() публичный статический метод

Searches through the scenes added to the SceneManager for a scene with the given name.

public static GetSceneByName ( string name ) : Scene
name string Name of scene to find.
Результат Scene

GetSceneByPath() публичный статический метод

Searches all scenes added to the SceneManager for a scene that has the given asset path.

public static GetSceneByPath ( string scenePath ) : Scene
scenePath string Path of the scene. Should be relative to the project folder. Like: "AssetsMyScenesMyScene.unity".
Результат Scene

LoadScene() публичный статический метод

Loads the scene by its name or index in Build Settings.

public static LoadScene ( int sceneBuildIndex, [ mode ) : void
sceneBuildIndex int Index of the scene in the Build Settings to load.
mode [ Allows you to specify whether or not to load the scene additively. /// See SceneManagement.LoadSceneMode for more information about the options.
Результат void

LoadScene() публичный статический метод

Loads the scene by its name or index in Build Settings.

public static LoadScene ( string sceneName, [ mode ) : void
sceneName string Name or path of the scene to load.
mode [ Allows you to specify whether or not to load the scene additively. /// See SceneManagement.LoadSceneMode for more information about the options.
Результат void

LoadSceneAsync() публичный статический метод

Loads the scene asynchronously in the background.

public static LoadSceneAsync ( int sceneBuildIndex, [ mode ) : AsyncOperation
sceneBuildIndex int Index of the scene in the Build Settings to load.
mode [ If LoadSceneMode.Single then all current scenes will be unloaded before loading.
Результат UnityEngine.AsyncOperation

LoadSceneAsync() публичный статический метод

Loads the scene asynchronously in the background.

public static LoadSceneAsync ( string sceneName, [ mode ) : AsyncOperation
sceneName string Name or path of the scene to load.
mode [ If LoadSceneMode.Single then all current scenes will be unloaded before loading.
Результат UnityEngine.AsyncOperation

MergeScenes() публичный статический метод

This 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.

public static MergeScenes ( Scene sourceScene, Scene destinationScene ) : void
sourceScene Scene The scene that will be merged into the destination scene.
destinationScene Scene Existing scene to merge the source scene into.
Результат void

MoveGameObjectToScene() публичный статический метод

Move a GameObject from its current scene to a new Scene. You can only move root GameObjects from one Scene to another. This means the GameObject to move must not be a child of any other GameObject in its Scene.

public static MoveGameObjectToScene ( GameObject go, Scene scene ) : void
go UnityEngine.GameObject GameObject to move.
scene Scene Scene to move into.
Результат void

SetActiveScene() публичный статический метод

Set the scene to be active.

public static SetActiveScene ( Scene scene ) : bool
scene Scene The scene to be set.
Результат bool

UnloadSceneAsync() публичный статический метод

Destroyes all GameObjects associated with the given scene and removes the scene from the SceneManager.

public static UnloadSceneAsync ( Scene scene ) : AsyncOperation
scene Scene Scene to unload.
Результат UnityEngine.AsyncOperation

UnloadSceneAsync() публичный статический метод

Destroyes all GameObjects associated with the given scene and removes the scene from the SceneManager.

public static UnloadSceneAsync ( int sceneBuildIndex ) : AsyncOperation
sceneBuildIndex int Index of the scene in BuildSettings.
Результат UnityEngine.AsyncOperation

UnloadSceneAsync() публичный статический метод

Destroyes all GameObjects associated with the given scene and removes the scene from the SceneManager.

public static UnloadSceneAsync ( string sceneName ) : AsyncOperation
sceneName string Name or path of the scene to unload.
Результат UnityEngine.AsyncOperation