public static void CloseEvolutionScene()
    {
        //Instead of having the GameSceneManager re-enable a scene once evolution scene closed, the scene being returned to should add a handler to EvolutionSceneClosed and resume once this is invoked

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

        StartFadeOut();

        FadeOutComplete += () =>
        {
            evolutionSceneInUse = false;

            //Wait until old scene unloaded before starting next scene
            SceneManager.UnloadSceneAsync(evolutionScene).completed += (ao) =>
            {
                StartFadeIn();

                FadeInComplete += () =>
                {
                    EvolutionSceneClosed?.Invoke();
                };
            };
        };
    }
Esempio n. 2
0
    public static void CloseEvolutionScene()
    {
        if (evolutionScene == null)
        {
            Debug.LogError("Evolution scene trying to be close while isn't already active");
            return;
        }

        StartFadeOut();

        FadeOutComplete += () =>
        {
            //Wait until old scene unloaded before starting next scene
            SceneManager.UnloadSceneAsync((Scene)evolutionScene).completed += (ao) =>
            {
                evolutionScene = null;

                StartFadeIn();

                FadeInComplete += () =>
                {
                    EvolutionSceneClosed?.Invoke();
                };
            };
        };
    }