private IEnumerator LoadScene(string scene) { AsyncOperation asyncLoading = SceneManager.LoadSceneAsync(scene); if (asyncLoading == null) { yield break; } asyncLoading.allowSceneActivation = false; UIPanelLoading loadingScreen = MainUI.Instance.LoadingPanel; float progress = 0; loadingScreen.SetLoadingBarProcess(progress); loadingScreen.FadeIn(); MusicManager.Instance.FadeOut(1f); yield return(new WaitForSeconds(1.0f)); while (progress <= 0.9f) { progress += 0.01f; loadingScreen.SetLoadingBarProcess(progress); yield return(new WaitForSeconds(0.01f)); } while (true) { if (asyncLoading.isDone || asyncLoading.progress > 0.89999f) { break; } yield return(0); } MusicManager.Instance.PlayMusic(eMusicSelection.BattleField, 2); loadingScreen.SetLoadingBarProcess(1); yield return(new WaitForSeconds(2.0f)); asyncLoading.allowSceneActivation = true; loadingScreen.FadeOut(); yield break; }
// Use this for initialization private void Start() { m_PanelLoading = Instantiate(m_PanelLoading, this.transform); m_PanelLoading.gameObject.SetActive(false); }