IEnumerator LoadAsynchronously(int sceneIndex) { loadingEvent.Invoke(); if (!(SceneManager.GetActiveScene().buildIndex == 0)) { pause.boolPause(false); } if (sceneIndex == 2) { FindObjectOfType <MusicManager>().ChangeMusicVolume("A", 0); FindObjectOfType <MusicManager>().ChangeMusicVolume("B", 1); } else { FindObjectOfType <MusicManager>().ChangeMusicVolume("A", 1); FindObjectOfType <MusicManager>().ChangeMusicVolume("B", 0); } loadingScreen.SetActive(true); loadingScreen.GetComponent <Image>().color = new Color(0, 0, 0, 0); if (pause != null) { pause.canPause = false; } Debug.Log("Switch scene to " + sceneIndex); anim.SetTrigger("Out"); yield return(new WaitForSeconds(2)); AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex); while (!operation.isDone) { float progress = Mathf.Clamp01(operation.progress / 0.9f); yield return(null); } }
IEnumerator LoadAsynchronously(int sceneIndex) { yield return(new WaitForSeconds(1)); if (!(SceneManager.GetActiveScene().buildIndex == 1)) { pause.boolPause(false); } loadingScreen.SetActive(true); if (pause != null) { pause.canPause = false; } Debug.Log("Switch scene to " + sceneIndex); anim.SetTrigger("FadeOut"); yield return(new WaitForSeconds(3)); AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex); }