private void UnloadOneBundle(string assetBundleName) { assetBundleName = AssetBundleHelper.BundleNameToLower(assetBundleName); ABInfo abInfo; if (!bundles.TryGetValue(assetBundleName, out abInfo)) { throw new Exception($"not found assetBundle: {assetBundleName}"); } //Log.Debug($"---------- unload one bundle {assetBundleName} refcount: {abInfo.RefCount - 1}"); --abInfo.RefCount; if (abInfo.RefCount > 0) { return; } bundles.Remove(assetBundleName); resourceCache.Remove(assetBundleName); abInfo.Dispose(); //Log.Debug($"cache count: {this.cacheDictionary.Count}"); }
public AssetBundle GetAssetBundle(string abName) { ABInfo abInfo; if (!bundles.TryGetValue(AssetBundleHelper.BundleNameToLower(abName), out abInfo)) { throw new Exception($"not found bundle: {abName}"); } return(abInfo.AssetBundle); }
public void UnloadBundle(string assetBundleName) { assetBundleName = AssetBundleHelper.BundleNameToLower(assetBundleName); string[] dependencies = DependenciesHelper.GetSortedDependencies(assetBundleName); //Log.Debug($"-----------dep unload {assetBundleName} dep: {dependencies.ToList().ListToString()}"); foreach (string dependency in dependencies) { UnloadOneBundle(dependency); } }
public void AddResource(string bundleName, string assetName, UnityEngine.Object resource) { Dictionary <string, UnityEngine.Object> dict; if (!resourceCache.TryGetValue(AssetBundleHelper.BundleNameToLower(bundleName), out dict)) { dict = new Dictionary <string, UnityEngine.Object>(); resourceCache[bundleName] = dict; } dict[assetName] = resource; }
public UnityEngine.Object GetAsset(string bundleName, string prefab) { Dictionary <string, UnityEngine.Object> dict; if (!resourceCache.TryGetValue(AssetBundleHelper.BundleNameToLower(bundleName), out dict)) { throw new Exception($"not found asset: {bundleName} {prefab}"); } UnityEngine.Object resource; if (!dict.TryGetValue(prefab, out resource)) { throw new Exception($"not found asset: {bundleName} {prefab}"); } return(resource); }