private IEnumerator Transition() { if (sceneToLoad < 0) { Debug.LogError("Scene to load not set"); yield break; } yield return(null); DontDestroyOnLoad(this.gameObject); LoadFader loadFader = FindObjectOfType <LoadFader>(); SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>(); loadFader.FadeOutImmediate(); savingWrapper.Save(); yield return(SceneManager.LoadSceneAsync(sceneToLoad)); yield return(savingWrapper.Load()); savingWrapper.Save(); loadFader.FadeInImmediate(); Time.timeScale = 1f; Destroy(this.gameObject); }
private IEnumerator ExitToMenu() { DontDestroyOnLoad(this.gameObject); LoadFader loadFader = FindObjectOfType <LoadFader>(); loadFader.FadeOutImmediate(); yield return(SceneManager.LoadSceneAsync(0)); loadFader.FadeInImmediate(); Time.timeScale = 1f; Destroy(this.gameObject); }