// ******************************************************************** // Function: LoadScene() // Purpose: Loads the supplied scene // ******************************************************************** public IEnumerator LoadSceneAsync(string sceneName) { // Fade to black yield return(StartCoroutine(m_blackScreenCover.FadeIn())); // Load loading screen yield return(Application.LoadLevelAsync("LoadingScreen")); // !!! unload old screen (automatic) // Fade to loading screen yield return(StartCoroutine(m_blackScreenCover.FadeOut())); float endTime = Time.time + m_minDuration; // Load level async yield return(Application.LoadLevelAdditiveAsync(sceneName)); while (Time.time < endTime) { yield return(null); } // Play music or perform other misc tasks // Fade to black yield return(StartCoroutine(m_blackScreenCover.FadeIn())); // !!! unload loading screen LoadingSceneManager.UnloadLoadingScene(); // Fade to new screen yield return(StartCoroutine(m_blackScreenCover.FadeOut())); }
// ******************************************************************** // Function: LoadScene() // Purpose: Loads the supplied scene // ******************************************************************** public IEnumerator LoadSceneAsync(string sceneName) { // Load loading screen yield return(Application.LoadLevelAsync("LoadingScreen")); // !!! unload old screen (automatic) float endTime = Time.time; // Load level async yield return(Application.LoadLevelAdditiveAsync(sceneName)); while (Time.time < endTime) { yield return(null); } // Play music or perform other misc tasks // !!! unload loading screen LoadingSceneManager.UnloadLoadingScene(); }