public void MoveScene(SCENENAME sceneName) { SoundManager.Instance.StopBGM(); loadingBar.fillAmount = 0f; _PrevScene_Name = (SCENENAME)SceneManager.GetActiveScene().buildIndex; //SoundController.Instance.AllSoundStop(false); _NextScene_Name = sceneName; Canvas_Loading.SetActive(true); Debug.Log("Canvas_Loading true :" + _NextScene_Name.ToString()); StartCoroutine("LoadScene"); }
IEnumerator LoadScene() { float chTime = 0f; AsyncOperation async_Empty = SceneManager.LoadSceneAsync("EmptyScene"); async_Empty.allowSceneActivation = false; float speed = 1f; while (loadingBar.fillAmount < 0.45f) { chTime += Time.deltaTime; //loadingBar.fillAmount = async_Empty.progress / 2f; loadingBar.fillAmount = Mathf.MoveTowards(loadingBar.fillAmount, (async_Empty.progress / 2f), Time.deltaTime * speed); yield return(null); } loadingBar.fillAmount = 0.5f; async_Empty.allowSceneActivation = true; //Canvas_Loading.SetActive(true); AsyncOperation async = SceneManager.LoadSceneAsync((int)_NextScene_Name); Debug.Log("Loading : " + _NextScene_Name.ToString()); async.allowSceneActivation = false; //chTime = 0f; while (loadingBar.fillAmount < 0.9f) { chTime += Time.deltaTime; loadingBar.fillAmount = Mathf.MoveTowards(loadingBar.fillAmount, (async_Empty.progress / 2f) + 0.5f, Time.deltaTime * speed); yield return(null); } while (chTime < loadingTime) { chTime += Time.deltaTime; yield return(null); } loadingBar.fillAmount = 1f; async.allowSceneActivation = true; yield return(null); //Canvas_Loading.SetActive(false); }