public static LoadName GetInstance() { if (instance == null) { instance = new LoadName(); } return(instance); }
//注意这里返回值一定是 IEnumerator IEnumerator LoadScene() { //yield return new WaitForEndOfFrame(); //异步读取场景。 //Globe.loadName 就是A场景中需要读取的C场景名称。 //async = Application.LoadLevelAsync(LoadName.GetInstance().loadName); async = SceneManager.LoadSceneAsync(LoadName.GetInstance().loadName); async.allowSceneActivation = false; while (async.progress < 0.9f) { toProgress = (int)(async.progress * 100); while (displayProgress < toProgress) { ++displayProgress; //LoadingAnimator(displayProgress); } yield return(new WaitForEndOfFrame());// 每次循环结束执行完当前帧才继续下一个循环 } toProgress = 100; while (displayProgress < toProgress) { ++displayProgress; //LoadingAnimator(displayProgress); yield return(new WaitForEndOfFrame()); } //CharacterPause(); yield return(new WaitForEndOfFrame()); async.allowSceneActivation = true; SystemController.StartSystem(); Time.timeScale = 1; ////读取完毕后返回, 系统会自动进入C场景 //yield return async; }
void Awake() { instance = this; }
/// <summary> /// 切换至该场景 /// </summary> public void EnterScene() { SceneManager.LoadScene("Loading"); //Application.LoadLevel("Loading"); LoadName.GetInstance().loadName = gameObject.name; }