/// <summary> /// /// </summary> /// <param name="onUpdate"></param> /// <returns></returns> IEnumerator LoadResourcesFromQueue(OnUpdateProgress onUpdate) { int total = m_loadingQueue.Count; LoadingProgressInfo prog = new LoadingProgressInfo(LoadingProgressType.Resource, m_loadingQueue.Count); onUpdate(prog); yield return(null); while (m_loadingQueue.Count > 0) { ResInfo res = m_loadingQueue.Dequeue(); switch (res.type) { case DataType.UnitData: LoadUnit(res.path); break; case DataType.ProjectileData: LoadProjectile(res.path); break; } prog.value += 1.0f; ; onUpdate(prog); yield return(null); } // yield return *; }
public IEnumerator LoadResourcesFromQueueAndReplaceScene(OnUpdateProgress onUpdate, CustomCoroutineFunction custom) { yield return(LoadResourcesFromQueue(onUpdate)); yield return(ReplaceScene(onUpdate)); if (custom != null) { yield return(custom(onUpdate)); } LoadingProgressInfo prog = new LoadingProgressInfo(LoadingProgressType.Done, 0.0f); onUpdate(prog); }
IEnumerator ReplaceScene(OnUpdateProgress onUpdate) { m_nextSceneAop = SceneManager.LoadSceneAsync(m_nextScene); m_nextSceneAop.allowSceneActivation = false; LoadingProgressInfo prog = new LoadingProgressInfo(LoadingProgressType.Scene, 0.9f); onUpdate(prog); yield return(null); while (m_nextSceneAop.progress < 0.9f) { prog.value = m_nextSceneAop.progress; onUpdate(prog); yield return(null); } prog.value = 0.9f; onUpdate(prog); yield return(null); }