public static void LaunchEvolutionScene()
    {
        //Evolution scene controller entrance arguments should have already been set before launching scene
        //Previous scene should have paused itself before launching the evolution scene

        RefreshCurrentSceneStack();

        if (evolutionSceneInUse)
        {
            Debug.LogError("Evolution scene trying to be launched while evolution scene already active");
            return;
        }

        EvolutionSceneClosed = null;

        Scene oldActiveScene = SceneManager.GetActiveScene();

        EvolutionSceneClosed += () =>
        {
            SceneManager.SetActiveScene(oldActiveScene);
        };

        StartFadeOut();

        FadeOutComplete += () =>
        {
            //https://low-scope.com/unity-quick-get-a-reference-to-a-newly-loaded-scene/
            int newSceneIndex = SceneManager.sceneCount;

            AsyncOperation loadSceneOperation = SceneManager.LoadSceneAsync(evolutionSceneIdentifier, LoadSceneMode.Additive);

            loadSceneOperation.completed += (ao) =>
            {
                evolutionScene      = SceneManager.GetSceneAt(newSceneIndex);
                evolutionSceneInUse = true;

                EvolutionScene.EvolutionSceneController evolutionSceneController = EvolutionScene.EvolutionSceneController.GetEvolutionSceneController(evolutionScene);

                SceneManager.SetActiveScene(evolutionScene);

                StartFadeIn();

                FadeInComplete += () =>
                {
                    evolutionSceneController.StartAnimation();

                    evolutionSceneController.EvolutionAnimationComplete += () =>
                    {
                        CloseEvolutionScene();
                    };
                };
            };
        };
    }
Esempio n. 2
0
    public static void LaunchEvolutionScene()
    {
        //Evolution scene controller entrance arguments should have already been set before launching scene
        //Previous scene should have paused itself before launching the evolution scene

        if (evolutionScene != null)
        {
            Debug.LogError("Evolution scene trying to be launched while one already active");
            return;
        }

        EvolutionSceneClosed = null;

        Scene oldScene = CurrentScene;

        EvolutionSceneClosed += () =>
        {
            SceneManager.SetActiveScene(oldScene);
        };

        StartFadeOut();

        FadeOutComplete += () =>
        {
            int newSceneIndex = SceneManager.sceneCount;

            AsyncOperation loadSceneOperation = SceneManager.LoadSceneAsync(evolutionSceneIdentifier, LoadSceneMode.Additive);

            loadSceneOperation.completed += (ao) =>
            {
                evolutionScene = SceneManager.GetSceneAt(newSceneIndex);

                EvolutionScene.EvolutionSceneController evolutionSceneController = EvolutionScene.EvolutionSceneController.GetEvolutionSceneController((Scene)evolutionScene);

                SceneManager.SetActiveScene((Scene)evolutionScene);

                StartFadeIn();

                FadeInComplete += () =>
                {
                    evolutionSceneController.StartAnimation();

                    evolutionSceneController.EvolutionAnimationComplete += () =>
                    {
                        CloseEvolutionScene();
                    };
                };
            };
        };
    }