public static void AllUnloadAssets() { BattleObjectPooler.CheckAndRemoveNull(); foreach (KeyValuePair <string, List <HitEffectParams> > keyValuePair in BattleObjectPooler.hitEffectParamsCache) { foreach (HitEffectParams hitEffectParams in keyValuePair.Value) { if (hitEffectParams.gameObject != null) { UnityEngine.Object.Destroy(hitEffectParams.gameObject); } } } BattleObjectPooler.hitEffectParamsCache.Clear(); foreach (KeyValuePair <string, List <AlwaysEffectParams> > keyValuePair2 in BattleObjectPooler.alwaysEffectParamsCache) { foreach (AlwaysEffectParams alwaysEffectParams in keyValuePair2.Value) { if (alwaysEffectParams.gameObject != null) { UnityEngine.Object.Destroy(alwaysEffectParams.gameObject); } } } BattleObjectPooler.alwaysEffectParamsCache.Clear(); Resources.UnloadUnusedAssets(); GC.Collect(); }
public static void CallInitialize() { if (!BattleObjectPooler.onInitialized) { BattleObjectPooler.Initialize(); BattleObjectPooler.onInitialized = true; } BattleObjectPooler.CheckAndRemoveNull(); }
private void CheckHeapAndCallRemove() { if (!this.CheckEnable) { return; } float num = (float)Profiler.usedHeapSizeLong; float num2 = (float)Profiler.GetTotalReservedMemoryLong(); float num3 = num / num2; if (num3 > 0.95f) { BattleObjectPooler.AllUnloadAssets(); } }
public static void SetAllDeactive() { BattleObjectPooler.CheckAndRemoveNull(); foreach (KeyValuePair <string, List <HitEffectParams> > keyValuePair in BattleObjectPooler.hitEffectParamsCache) { foreach (HitEffectParams hitEffectParams in keyValuePair.Value) { hitEffectParams.transform.SetParent(BattleObjectPooler.cacheRoot); hitEffectParams.gameObject.SetActive(false); } } foreach (KeyValuePair <string, List <AlwaysEffectParams> > keyValuePair2 in BattleObjectPooler.alwaysEffectParamsCache) { foreach (AlwaysEffectParams alwaysEffectParams in keyValuePair2.Value) { alwaysEffectParams.transform.SetParent(BattleObjectPooler.cacheRoot); alwaysEffectParams.gameObject.SetActive(false); } } }
public void RemoveAllCachedObjects() { BattleObjectPooler.SetAllDeactive(); if (this._commandSelectTweenTargetCamera != null) { UnityEngine.Object.Destroy(this._commandSelectTweenTargetCamera.gameObject); } if (this._stageObject != null) { UnityEngine.Object.Destroy(this._stageObject); } foreach (SpawnPointParams spawnPointParams in this._preloadSpawnPoints.GetAllObject()) { if (spawnPointParams != null) { UnityEngine.Object.Destroy(spawnPointParams.gameObject); } } foreach (CharacterParams characterParams in this._preloadEnemiesParams.GetAllObject()) { if (!(characterParams == null)) { UnityEngine.Object.Destroy(characterParams.gameObject); } } foreach (CharacterStateControl characterStateControl in this._playerCharacters) { if (!(characterStateControl.CharacterParams == null)) { UnityEngine.Object.Destroy(characterStateControl.CharacterParams.gameObject); } } foreach (HitEffectParams array in this.hitEffects.GetAllObject()) { foreach (HitEffectParams hitEffectParams in array) { if (hitEffectParams != null && !BattleObjectPooler.ContainHitEffectParams(hitEffectParams)) { UnityEngine.Object.Destroy(hitEffectParams.gameObject); } } } if (this._drainEffect != null) { UnityEngine.Object.Destroy(this._drainEffect.gameObject); } foreach (AlwaysEffectParams alwaysEffectParams in this._revivalReservedEffect) { if (alwaysEffectParams != null && !BattleObjectPooler.ContainAlwaysEffectParams(alwaysEffectParams)) { UnityEngine.Object.Destroy(alwaysEffectParams.gameObject); } } foreach (AlwaysEffectParams alwaysEffectParams2 in this._droppingItemNormalEffect) { if (alwaysEffectParams2 != null && !BattleObjectPooler.ContainAlwaysEffectParams(alwaysEffectParams2)) { UnityEngine.Object.Destroy(alwaysEffectParams2.gameObject); } } foreach (AlwaysEffectParams alwaysEffectParams3 in this._droppingItemRareEffect) { if (alwaysEffectParams3 != null && !BattleObjectPooler.ContainAlwaysEffectParams(alwaysEffectParams3)) { UnityEngine.Object.Destroy(alwaysEffectParams3.gameObject); } } if (this._winCameraMotionInternalResources != null) { UnityEngine.Object.Destroy(this._winCameraMotionInternalResources.gameObject); } BattleObjectPooler.isCheckEnable = true; Resources.UnloadUnusedAssets(); GC.Collect(); }