void Update_initPlayer() { switch (initPlayProcess) { case InitProcess.GetName: ///先取得昵称和使用的角色 initPlayProcess = InitProcess.Waiting; StartCoroutine(GetName()); break; case InitProcess.Waiting: break; case InitProcess.InitModel: ///在场景中实例化角色 ///这个方法中途可能会中断,例如中途加载DLC中的资源,或者下载 /// 所以,实例化一个角色可能是同步也可能是异步 ///继续等待 initPlayProcess = InitProcess.Waiting; ///异步实例化模型 StartCoroutine(InitCharator()); break; case InitProcess.Finish: ///加载玩家全部完成 GameState = GameState.Running; break; default: break; } }
private IEnumerator InitCharator() { initPlayProcess = InitProcess.Waiting; Task async = CharatorManager.InstantiatePlayer(); while (!async.IsDone) { yield return null; } initPlayProcess = InitProcess.Finish; }
private IEnumerator InitCharator() { initPlayProcess = InitProcess.Waiting; Task async = CharatorManager.InstantiatePlayer(); while (!async.IsDone) { yield return(null); } initPlayProcess = InitProcess.Finish; }
private IEnumerator GetName() { while (!SplashDone) { ///等待闪屏结束 yield return null; } yield return StartCoroutine(GetNiCheng()); yield return StartCoroutine(ChooseCharator()); ///名字已经拿到,初始化模型吧 initPlayProcess = InitProcess.InitModel; }
private IEnumerator GetName() { while (!SplashDone) { ///等待闪屏结束 yield return(null); } yield return(StartCoroutine(GetNiCheng())); yield return(StartCoroutine(ChooseCharator())); ///名字已经拿到,初始化模型吧 initPlayProcess = InitProcess.InitModel; }