// 关闭UI,根据类型不同,触发不同行为 public static void CloseUI(UIPathData pathData) { if (null == m_instance) { return; } //int MaxCloseCount = PlayerPreferenceData.MaxCleanUICount; //if (MaxCloseCount > 6) //{ // MaxCloseCount = 6; //} //关闭MaxCloseCount次UI的时候,立即GC //if (++m_sCloseUICount >= MaxCloseCount) //{ // Resources.UnloadUnusedAssets(); // GC.Collect(); // m_sCloseUICount = 0; // // LogModule.DebugLog("CloseUI GC 1"); //} //else //{ // //活动,侠客,世界地图,PK,酒楼, 美人,背包界面,伙伴,每次打开都清理 // if (pathData.name == "ActivityController" || // pathData.name == "SwordsManController" || // pathData.name == "SceneMapRoot" || // pathData.name == "PKSetRoot" || // pathData.name == "Restaurant" || // pathData.name == "BelleController" || // pathData.name == "BackPackRoot" || // pathData.name == "PartnerAndMountRoot") // { // Resources.UnloadUnusedAssets(); // GC.Collect(); // m_sCloseUICount = 0; // //LogModule.DebugLog("CloseUI GC 2 " + pathData.name); // } //} //LogModule.DebugLog("m_sCloseUICount : " + m_sCloseUICount + " MaxCloseCount= " + MaxCloseCount); //if (!m_GCTimerGo) //{ // //关闭UI的时候,如果玩家不会进行其他操作,则顺手清理一下内存 // //如果关闭UI的时候玩家需要流畅的玩耍,则要排除掉 // //目前先增加特例,之后等特例多了之后进行统一处理 // if (pathData.name != "NewPlayerGuidRoot") // { // m_GCTimerGo = true; // m_GCWaitTime = Time.fixedTime; // } //} if (pathData.name.Equals("BelleController")) { BundleManager.DoUnloadUnuseBundle(); } #if UNITY_WP8 m_UnloadBundle = false; #endif #if UNITY_ANDROID if (!PlatformHelper.IsChannelMainland()) { PopOpenedList(false); } #endif m_instance.RemoveLoadDicRefCount(pathData.name); switch (pathData.uiType) { case UIPathData.UIType.TYPE_BASE: m_instance.CloseBaseUI(pathData.name); break; case UIPathData.UIType.TYPE_POP: m_instance.ClosePopUI(pathData.name); break; case UIPathData.UIType.TYPE_STORY: m_instance.CloseStoryUI(pathData.name); break; case UIPathData.UIType.TYPE_TIP: m_instance.CloseTipUI(pathData.name); break; case UIPathData.UIType.TYPE_MENUPOP: m_instance.CloseMenuPopUI(pathData.name); break; case UIPathData.UIType.TYPE_MESSAGE: m_instance.CloseMessageUI(pathData.name); break; case UIPathData.UIType.TYPE_DEATH: m_instance.CloseDeathUI(pathData.name); break; default: break; } #if UNITY_WP8 //windows phone 清理 assetbundle if (m_UnloadBundle && pathData.uiType != UIPathData.UIType.TYPE_BASE && pathData.uiType != UIPathData.UIType.TYPE_MESSAGE) { if (pathData.uiType != UIPathData.UIType.TYPE_TIP) { ClearUIBundle(m_itemBundleNameList); m_itemBundleNameList.Clear(); m_UnloadItemBundle = false; } ClearUIBundleAsyc(pathData.name); } #endif if (pathData.uiGroupName != null && pathData.isMainAsset) { BundleManager.ReleaseLoginBundle(); #if UNITY_WP8 BundleManager.ReleaseSingleGroupBundle(pathData.uiGroupName); #endif } }
IEnumerator GCAfterOneSceond() { yield return(new WaitForSeconds(1)); BundleManager.DoUnloadUnuseBundle(); }
IEnumerator LoadScene() { //m_ClipSlider.SetNextProgress(0.9f); LabelLoadingProgressNum1.text = "90%"; LabelLoadingProgressNum2.text = "90%"; SliderLoading1.value = 0.9f; BundleManager.ReleaseSingleBundle(); BundleManager.CleanBundleLoadQueue(); BundleManager.ReleaseUIRefBundle(); BundleManager.DoUnloadUnuseBundle(); Obj_Character.s_hasPlayedBornEffectObjIdList.Clear(); if (null != m_lastSceneBundle) { m_lastSceneBundle.Unload(false); m_lastSceneBundle = null; } ResourcesManager.Instance.UnLoadAll(); BundleManager.ReleaseUIGroupBundle(); if (nextSceneID != (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_LOGIN) { BundleManager.ReleaseLoginBundle(); LogModule.ErrorLog("Resources.UnloadUnusedAssets"); yield return(Resources.UnloadUnusedAssets()); System.GC.Collect(); yield return(StartCoroutine(BundleManager.LoadMainUI())); yield return(StartCoroutine(BundleManager.LoadUI(UIInfo.JoyStickRoot, null, null, null))); DamageBoardManager.PreloadDamageBoard(); } else { BundleManager.ReleaseGroupBundle(); LogModule.ErrorLog("Resources.UnloadUnusedAssets"); yield return(Resources.UnloadUnusedAssets()); System.GC.Collect(); yield return(StartCoroutine(BundleManager.LoadLoginUI())); } yield return(StartCoroutine(BundleManager.LoadCommonShader())); if (nextSceneID == (int)Games.GlobeDefine.GameDefine_Globe.SCENE_DEFINE.SCENE_LOGIN) { GameManager.gameManager.RunningScene = (int)LoadingWindow.nextSceneID; AsyncOperation curAsync = Application.LoadLevelAsync((int)LoadingWindow.nextSceneID); while (!curAsync.isDone) { //SetProgress(curAsync.progress); //m_ClipSlider.SetNextProgress(0.9f + 0.1f * curAsync.progress); StringBuilder sb = new StringBuilder(""); sb.AppendFormat("{0}%", (int)(curAsync.progress * 100)); LabelLoadingProgressNum1.text = sb.ToString(); LabelLoadingProgressNum2.text = sb.ToString(); SliderLoading1.sliderValue = curAsync.progress; //loadingSlider.value = curAsync.progress; yield return(null); } //m_ClipSlider.SetProgress(1f); LabelLoadingProgressNum1.text = "100%"; LabelLoadingProgressNum2.text = "100%"; SliderLoading1.sliderValue = 1.0f; //loadingSlider.value = 1; } else { m_ClipSlider.SetNextProgress(1f); SliderLoading1.sliderValue = 0.95f; LabelLoadingProgressNum2.text = "95%"; // 这个地方改为读表,不读GlobeDefine的静态字符串 Tab_SceneClass sceneClass = TableManager.GetSceneClassByID((int)LoadingWindow.nextSceneID, 0); if (sceneClass == null) { LogModule.ErrorLog("Cant load scene id: {0}", (int)LoadingWindow.nextSceneID); yield return(null); } else { yield return(StartCoroutine(BundleManager.LoadScene(sceneClass.ResName, LoadSceneFinish))); } } }