public static IEnumerator LoadIntroMessages() { for (int i = 0; i < instance.nbMessages; i++) { // activate the message to display instance.listOfMessages[i].gameObject.SetActive(true); if (i != 0) { // fade out yield return(FadingBackground.FadeOutAsync()); } // wait for durationInSeconds seconds yield return(new WaitForSeconds(instance.durationInSeconds)); if (i < instance.nbMessages - 1) { // fade in yield return(FadingBackground.FadeInAsync()); // deactivate current message instance.listOfMessages[i].gameObject.SetActive(false); } } SceneLoader.LoadNextScene(); }
public static IEnumerator ResetScene(float fadeInDuration = -1f) { yield return(FadingBackground.FadeInAsync(fadeInDuration)); SceneManager.LoadScene(SceneManager.GetActiveScene().name); yield return(FadingBackground.FadeOutAsync()); yield return(AudioSourceFader.instance.FadeInSound(5f)); }
public IEnumerator ReturnToMainMenuAsync() { yield return(FadingBackground.FadeInAsync()); SceneManager.LoadScene(loadLevel); yield return(FadingBackground.FadeOutAsync()); StartCoroutine(AudioSourceFader.instance.FadeInSound(10f)); }
void Awake() { if (instance == null) { instance = this; image.enabled = false; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
IEnumerator Start() { splashImage.canvasRenderer.SetAlpha(0.0f); splashMessage.canvasRenderer.SetAlpha(0.0f); FadeIn(); yield return(new WaitForSeconds(2.5f)); FadeOut(); if (FadingBackground.GetFadeInDuration() < 2.5f) { yield return(new WaitForSeconds(2.5f - FadingBackground.GetFadeInDuration())); } yield return(FadingBackground.FadeInAsync()); SceneManager.LoadScene(loadLevel); yield return(FadingBackground.FadeOutAsync()); StartCoroutine(AudioSourceFader.instance.FadeInSound(10f)); }
// The coroutine runs on its own at the same time as Update() and takes an integer indicating which scene to load. public static IEnumerator LoadScene(string sceneName) { // Fade to black instance.StartCoroutine(AudioSourceFader.instance.FadeOutSound(1.5f)); yield return(FadingBackground.FadeInAsync()); // Load loading screen yield return(SceneManager.LoadSceneAsync(instance.loadingScene)); Debug.Log("Loading screen loaded"); // Fade to loading screen yield return(FadingBackground.FadeOutAsync()); float endTime = Time.time + instance.minDuration; // Load level async // good way to load with loading screen AsyncOperation async = SceneManager.LoadSceneAsync(sceneName); async.allowSceneActivation = false; if (Time.time < endTime) { yield return(new WaitForSeconds(endTime - Time.time)); } yield return(FadingBackground.FadeInAsync()); async.allowSceneActivation = true; yield return(FadingBackground.FadeOutAsync()); instance.StartCoroutine(AudioSourceFader.instance.FadeInSound(10f)); }