/// <inheritdoc cref="UnityResources.UnloadUnusedAssets()"/> public static AsyncOperation UnloadUnusedAssets() { AsyncOperation operation = UnityResources.UnloadUnusedAssets(); operation.completed += unloadCacheAsync; return(operation); }
/// <summary> /// 清空资源 /// </summary> /// <param name="gc">If set to <c>true</c> gc.</param> public void ClearCache(bool gc) { lstRefAsset = new LRUCache <string, UObj>(MAX_CAPACITY, MAX_CAPACITY); unUsedUObj = 0; if (gc) { URes.UnloadUnusedAssets(); } }
void releaseRes(KeyValuePair <string, UObj>[] toBeRm) { if (toBeRm != null) { unUsedUObj += toBeRm.Length; if (unUsedUObj >= MAX_UNUSED_OBJ) { URes.UnloadUnusedAssets(); } unUsedUObj = 0; } toBeRm = null; }
public void Destory(string name) { if (string.IsNullOrEmpty(name)) { return; } bool exist = lstRefAsset.Delete(name); if (exist) { unUsedUObj++; } if (unUsedUObj >= MAX_UNUSED_OBJ) { URes.UnloadUnusedAssets(); } unUsedUObj = 0; }
/// <summary> /// 清空资源 /// </summary> /// <param name="gc">If set to <c>true</c> gc.</param> public void ClearCache(bool gc) { KeyValuePair <string, AssetBundle>[] all = lstRefAsset.Clear(); if (all != null) { int len = all.Length; if (len <= 0) { return; } for (int i = 0; i < len; ++i) { all[i].Value.Unload(true); } } if (gc) { URes.UnloadUnusedAssets(); } }