public static void UnInitGameResource() { if (AppEnv.IsUseAB) { BundleManager.UnInitGameBundle(); } ResourcePoolManager.ClearPools(); }
private static void UnloadUnusedAssets(bool forceGc = false, bool clearPool = false) { #if UNITY_EDITOR var watch = Stopwatch.StartNew(); long totalTime = 0; long clearPoolTime = 0; long unloadResTime = 0; long gcTime = 0; #endif ResourceManager._lastReleaseTime = Time.time; if (clearPool) { ResourcePoolManager.ClearPools(); } #if UNITY_EDITOR watch.Stop(); totalTime += watch.ElapsedMilliseconds; clearPoolTime = watch.ElapsedMilliseconds; watch.Reset(); watch.Start(); #endif Resources.UnloadUnusedAssets(); #if UNITY_EDITOR watch.Stop(); totalTime += watch.ElapsedMilliseconds; unloadResTime = watch.ElapsedMilliseconds; watch.Reset(); watch.Start(); #endif if (forceGc) { GC.Collect(0, GCCollectionMode.Forced); } #if UNITY_EDITOR watch.Stop(); totalTime += watch.ElapsedMilliseconds; gcTime = watch.ElapsedMilliseconds; watch.Reset(); watch.Start(); watch.Stop(); LogHelper.WARN( "ResManager", "UnloadUnusedAssets({0}, {1}) used {2}ms(CP{3},UL{4},GC{5})", forceGc ? "GC" : "--", clearPool ? "CP" : "--", totalTime, clearPoolTime, unloadResTime, gcTime); #endif }
void OnDestroy() { ResourcePoolManager.ClearPools(); }