private void OnUnLoadSceneComplete(SceneLoaderRoutine routine) { m_SceneLoaderList.Remove(routine); GameEntry.Pool.EnqueueClassObject(routine); m_CurrLoadOrUnloadSceneDetailCount++; if (m_NeedLoadOrUnloadSceneDetailCount == m_CurrLoadOrUnloadSceneDetailCount) { Resources.UnloadUnusedAssets(); m_NeedLoadOrUnloadSceneDetailCount = 0; m_CurrLoadOrUnloadSceneDetailCount = 0; LoadNewScene(); } }
/// <summary> /// 加载新场景 /// </summary> private void LoadNewScene() { m_CurrSceneEntity = GameEntry.DataTable.DataTableManager.Sys_SceneDBModel.Get(m_CurrLoadSceneId); m_CurrSceneDetailList = GameEntry.DataTable.DataTableManager.Sys_SceneDatailDBModel.GetListBySceneId(m_CurrSceneEntity.Id, 2); m_NeedLoadOrUnloadSceneDetailCount = m_CurrSceneDetailList.Count; for (int i = 0; i < m_NeedLoadOrUnloadSceneDetailCount; i++) { SceneLoaderRoutine routine = GameEntry.Pool.DequeueClassObject <SceneLoaderRoutine>(); m_SceneLoaderList.AddLast(routine); Sys_SceneDatailEntity entity = m_CurrSceneDetailList[i]; routine.LoadScene(entity.Id, entity.ScenePath, OnLoadSceneProgressUpdate, OnLoadSceneComplete); } }
/// <summary> /// 卸载当前场景 /// </summary> private void UnLoadCurrScene() { if (m_CurrSceneEntity != null) { m_NeedLoadOrUnloadSceneDetailCount = m_CurrSceneDetailList.Count; for (int i = 0; i < m_NeedLoadOrUnloadSceneDetailCount; i++) { SceneLoaderRoutine routine = GameEntry.Pool.DequeueClassObject <SceneLoaderRoutine>(); m_SceneLoaderList.AddLast(routine); routine.UnLoadScene(m_CurrSceneDetailList[i].ScenePath, OnUnLoadSceneComplete); } } else { LoadNewScene(); } }
private void OnLoadSceneComplete(SceneLoaderRoutine routine) { m_SceneLoaderList.Remove(routine); GameEntry.Pool.EnqueueClassObject(routine); }