/// <summary> /// 目标引用减一 /// </summary> /// <param name="hashcode"></param> /// <returns></returns> public static int Subtract(int hashcode) { #if UNITY_EDITOR if (ManifestManager.SimulateAssetBundleInEditor) { return(1); } #endif CacheData cached = CacheManager.TryGetCache(hashcode); if (cached != null && cached.count >= 1) { cached.count--; // = cached.count - 1; #if HUGULA_CACHE_DEBUG HugulaDebug.FilterLogFormat(cached.assetBundleKey, " <color=#8cacbc>Subtract (assetBundle={0},hashcode={1},count={2}) frameCount{3}</color>", cached.assetBundleKey, hashcode, cached.count, UnityEngine.Time.frameCount); #endif if (cached.count == 0) //所有引用被清理。 { int[] alldep = cached.dependencies; CacheManager.ClearDelay(hashcode); int tmpDenHash = 0; if (alldep != null) { for (int i = 0; i < alldep.Length; i++) { tmpDenHash = alldep[i]; if (tmpDenHash != hashcode) { Subtract(tmpDenHash); } } } } return(cached.count); } #if UNITY_EDITOR || !HUGULA_RELEASE else if (cached != null && cached.count <= 0) { UnityEngine.Debug.LogWarningFormat("CountManager.Subtract (assetBundle={0},hashcode={1},count={2}) frameCount{3}", cached.assetBundleKey, hashcode, cached.count, UnityEngine.Time.frameCount); } #endif return(-1); }
/// <summary> /// 目标引用减一 /// </summary> /// <param name="hashcode"></param> /// <returns></returns> public static int Subtract(int hashcode) { #if UNITY_EDITOR if (CResLoader.SimulateAssetBundleInEditor) { return(1); } #endif CacheData cached = CacheManager.TryGetCache(hashcode); if (cached != null && cached.count >= 1) { cached.count--; // = cached.count - 1; #if HUGULA_CACHE_DEBUG UnityEngine.Debug.LogFormat(" <color=#8cacbc>Subtract (assetBundle={0},count={1}) frameCount{2}</color>", cached.assetBundleKey, cached.count, UnityEngine.Time.frameCount); #endif if (cached.count == 0) //所有引用被清理。 { CacheManager.ClearDelay(hashcode); int[] alldep = cached.allDependencies; CacheData cachetmp = null; if (alldep != null) { for (int i = 0; i < alldep.Length; i++) { cachetmp = CacheManager.TryGetCache(alldep[i]); if (cachetmp != null && cachetmp.assetHashCode != hashcode) { Subtract(cachetmp.assetHashCode); } } } } return(cached.count); } #if UNITY_EDITOR else if (cached != null && cached.count <= 0) { UnityEngine.Debug.LogFormat(" <color=#ffff00>Subtract (assetBundle={0},count={1}) frameCount{2}</color>", cached.assetBundleKey, cached.count, UnityEngine.Time.frameCount); } #endif return(-1); }