Exemplo n.º 1
0
        /// <summary>
        /// Callback for a finished async level load.
        /// Marks scene as active if it's name matches activeSceneName.
        /// Removes scene name from currentlyLoadingSceneNames and adds it to loadedSceneNames.
        /// </summary>
        /// <param name="loadedScene">Scene that finished loading</param>
        void FinishLoadingScene(Scene loadedScene)
        {
            if (loadedScene.name == ManagerScene)
            {
                return;
            }

            if (loadedScene.name == activeSceneName)
            {
                SceneManager.SetActiveScene(loadedScene);
                OnActiveSceneChange?.Invoke();
            }

            AfterSceneLoad?.Invoke(loadedScene.name);

            if (currentlyLoadingSceneNames.Contains(loadedScene.name))
            {
                currentlyLoadingSceneNames.Remove(loadedScene.name);
            }

            if (!loadedSceneNames.Contains(loadedScene.name))
            {
                loadedSceneNames.Add(loadedScene.name);
            }
        }
Exemplo n.º 2
0
    void OnActiveSceneChanged(Scene currentScene, Scene nextScene)
    {
        if (currentSceneBuildIndex == -1)
        {
            currentSceneBuildIndex = nextScene.buildIndex;
            return;
        }

        if (currentSceneBuildIndex != nextScene.buildIndex)
        {
            currentSceneBuildIndex = nextScene.buildIndex;
            OnActiveSceneChange?.Invoke();
        }
    }