예제 #1
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load is not set.");
                yield break;
            }

            DontDestroyOnLoad(this.gameObject);

            Fader            fader            = FindObjectOfType <Fader>();
            SavingWrapper    savingWrapper    = FindObjectOfType <SavingWrapper>();
            PlayerController playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            playerController.enabled = false;

            yield return(fader.FadeOut(fadeOutTime));

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            PlayerController newPlayerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            newPlayerController.enabled = false;


            savingWrapper.RestorePlayerAfterSceneChange();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            fader.FadeIn(fadeInTime);

            newPlayerController.enabled = true;
            Destroy(this.gameObject);
        }