private IEnumerator Transition() { // Preserve this portal for now DontDestroyOnLoad(this.gameObject); // Fade Out yield return(fader.FadeOut(fadeTimeBetweenScenes)); // Save current level state savingWrapper.SaveMethod(); // Load Async yield return(SceneManager.LoadSceneAsync(sceneToLoad)); // Load next level state savingWrapper.LoadMethod(); print("He"); // Update player position based on future portal spawnpoint UpdatePlayer(GetOtherPortal()); // Save as a checkpoint savingWrapper.SaveMethod(); // Fade In yield return(fader.FadeIn(fadeTimeBetweenScenes)); // Finally, destroy the old portal Destroy(this.gameObject); }
public IEnumerator Transition() { DontDestroyOnLoad(gameObject); Fader fader = FindObjectOfType <Fader>(); yield return(fader.FadeOut(fadeOutTime)); SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>(); savingWrapper.Save(); yield return(SceneManager.LoadSceneAsync(sceneToLoad)); savingWrapper.Load(); PortalController otherPortal = GetOtherPortal(); UpdatePlayer(otherPortal); savingWrapper.Save(); yield return(new WaitForSeconds(fadeWaitTime)); yield return(fader.FadeIn(fadeInTime)); Destroy(gameObject); }