UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync C# (CSharp) Method

UnloadSceneAsync() public static method

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.
return UnityEngine.AsyncOperation
        public static AsyncOperation UnloadSceneAsync(Scene scene)
        {
            bool flag;
            return UnloadSceneNameIndexInternal("", scene.buildIndex, false, out flag);
        }

Same methods

SceneManager::UnloadSceneAsync ( int sceneBuildIndex ) : AsyncOperation
SceneManager::UnloadSceneAsync ( string sceneName ) : AsyncOperation

Usage Example

コード例 #1
0
ファイル: GameStart.cs プロジェクト: linxscc/bnyx
    IEnumerator LoadSceneGame(int weight)
    {
        Scene scene = SceneManager.GetSceneByName("Game");

        if (scene.isLoaded)
        {
            _asyncOperation = SceneManager.UnloadSceneAsync(scene);
            while (!_asyncOperation.isDone)
            {
                yield return(0);
            }
        }

        _asyncOperation = SceneManager.LoadSceneAsync("Game", LoadSceneMode.Additive);
        _asyncOperation.allowSceneActivation = false;
        yield return(0);

        float progress = 0;

        while (!_asyncOperation.isDone)
        {
            progress = _asyncOperation.progress < 0.9f ? _asyncOperation.progress : 1;

            yield return(progress * weight);

            if (progress >= 0.9f)
            {
                _asyncOperation.allowSceneActivation = true;
            }
        }
    }
All Usage Examples Of UnityEngine.SceneManagement.SceneManager::UnloadSceneAsync