public static AssetBundleLoad Take(string assetBundleName) { AssetBundleLoad assetBundleLoad; if (allAssetBundleDic.TryGetValue(assetBundleName, out assetBundleLoad) == false) { //todo 验证是ab包名正确性 assetBundleLoad = new AssetBundleLoad(); allAssetBundleDic.Add(assetBundleName, assetBundleLoad); assetBundleLoad.referenceCount = 0; assetBundleLoad.loadState = LoadState.NotLoad; assetBundleLoad.assetBundleName = assetBundleName; assetBundleLoad.allAsset = new Dictionary <string, Object>(); assetBundleLoad.referenceCount++; return(assetBundleLoad); } else { assetBundleLoad.referenceCount++; return(assetBundleLoad); } }
public AssetsLoad(string assetBundleName) { if (EditorAssetLoad.LocalLoadModel) { editorAssetLoad = EditorAssetLoad.Take(assetBundleName); } else { assetBundleLoad = AssetBundleLoad.Take(assetBundleName); } }
public void UnLoad() { if (EditorAssetLoad.LocalLoadModel) { EditorAssetLoad.Put(editorAssetLoad); editorAssetLoad = null; } else { AssetBundleLoad.Put(assetBundleLoad); assetBundleLoad = null; } }
public static void Put(AssetBundleLoad assetBundleLoad) { if (assetBundleLoad.referenceCount == 1) { assetBundleLoad.referenceCount = 0; foreach (var assetBundleLoadDeoend in assetBundleLoad.assetBundleLoadDependencies) { Put(assetBundleLoadDeoend); } assetBundleLoad.loadState = LoadState.Unload; assetBundleLoad.assetBundle.Unload(true); assetBundleLoad.assetBundle = null; assetBundleLoad.allAsset.Clear(); } else { assetBundleLoad.referenceCount--; } }