public IEnumerator ChangeCoroutine(SceneName scene) { yield return(StartCoroutine(Fade.Instance().FadeOutCoroutine(1.0f, Color.black))); UnityEngine.SceneManagement.SceneManager.LoadScene(scene.String()); Fade.Instance().FadeIn(1.0f, Color.black); }
/// <summary> /// 非同期ロード /// </summary> /// <returns></returns> private IEnumerator LoadData(SceneName scene) { //ロードキャンパス生成 loadCanvas = Instantiate((GameObject)Resources.Load("Prefab/LoadCanvas")); yield return(new WaitForSeconds(0.5f)); Image loadImage = loadCanvas.GetComponentInChildren <Image>(); Text loadText = loadCanvas.GetComponentInChildren <Text>(); //読み込んでる感を出す var elapsed = 0f; while (elapsed < waitBeforeLoadingSeconds) { var t = Time.time; yield return(null); elapsed += (Time.time - t); var par = Mathf.Clamp01(elapsed / waitBeforeLoadingSeconds); loadText.text = (par * waitBeforeLoadingAmount * 100).ToString("F0") + "%"; } loadText.text = (waitBeforeLoadingAmount * 100).ToString("F0") + "%"; //実際の読み込みで進むパーセンテージの計算 var remine = (1f - waitBeforeLoadingAmount); UnityEngine.Assertions.Assert.IsTrue(remine > 0); //非同期読み込みを開始 AsyncOperation async = SceneManager.LoadSceneAsync(scene.String()); async.allowSceneActivation = false; // シーン遷移をしない while (async.progress < 0.9f) { //ロード進展 //サークル回転はアニメーションで loadText.text = ((waitBeforeLoadingAmount + (remine * async.progress)) * 100).ToString("F0") + "%"; yield return(new WaitForEndOfFrame()); } loadText.text = "100%"; yield return(new WaitForSeconds(0.5f)); //ステージ名表示 yield return(StartCoroutine(StageName(scene))); async.allowSceneActivation = true;// シーン遷移許可 }
/// <summary> /// シーンの変更 /// </summary> /// <param name="scene">次のシーン</param> public void Change(SceneName scene) { SceneManager.LoadScene(scene.String()); }