public void RemoveAssetBundleCat(AssetBundleCat assetBundleCat) { if (assetBundleCat == null) { return; } LogCat.log(assetBundleCat.assetBundleName + " removed"); assetBundleCat.Get()?.Unload(true); //最关键的一步 assetBundleCatDict.RemoveByFunc((key, value) => value == assetBundleCat); }
protected override void _Destroy() { base._Destroy(); assetBundleCat = null; _needDownloadBytes = null; if (www != null) { www.Dispose(); www = null; } }
public void Init(AssetBundleCat assetBundleCat) { this.assetBundleName = assetBundleName; this.assetBundleCat = assetBundleCat; // 只添加没有被加载过的 if (!assetBundleCat.IsLoadDone()) { waitingAssetBundleCatDict[assetBundleCat.assetBundleName] = assetBundleCat; assetBundleDownloadedBytesDict[assetBundleCat.assetBundleName] = 0; } for (var i = 0; i < assetBundleCat.dependenceAssetBundleCatList.Count; i++) { var dependenceAssetBundleCat = assetBundleCat.dependenceAssetBundleCatList[i]; if (dependenceAssetBundleCat.IsLoadDone()) { continue; } waitingAssetBundleCatDict[dependenceAssetBundleCat.assetBundleName] = dependenceAssetBundleCat; assetBundleDownloadedBytesDict[dependenceAssetBundleCat.assetBundleName] = 0; } totalWaitingAssetBundleCatCount = waitingAssetBundleCatDict.Count; needDownloadBytes = 0; foreach (var keyValue in assetBundleDownloadedBytesDict) { var curAssetBundleName = keyValue.Key; needDownloadBytes += Client.instance.assetBundleManager.assetBundleMap.dict[curAssetBundleName]; } if (totalWaitingAssetBundleCatCount == 0) { resultInfo.isSuccess = true; return; } AddListener <ResourceWebRequester>(null, AssetBundleEventNameConst.On_ResourceWebRequester_Fail, OnResourceWebRequesterFail); AddListener <ResourceWebRequester>(null, AssetBundleEventNameConst.On_ResourceWebRequester_Success, OnResourceWebRequesterSuccess); }
private bool CreateAssetBundleAsync(string assetBundleName) { if (__IsAssetBundleLoadSuccess(assetBundleName) || resourceWebRequesterAllDict.ContainsKey(assetBundleName)) { return(false); } // webRequester持有的引用,webRequester结束后会删除该次引用(在AssetBunldeMananger中的OnProsessingWebRequester的进行删除本次引用操作) var assetBundleCat = new AssetBundleCat(assetBundleName); assetBundleCat.AddRefCount(); AddAssetBundleCat(assetBundleCat); var resourceWebRequester = PoolCatManagerUtil.Spawn <ResourceWebRequester>(); var url = assetBundleName.WithRootPath(FilePathConst.PersistentAssetBundleRoot); resourceWebRequester.Init(assetBundleCat, url); resourceWebRequesterAllDict[assetBundleName] = resourceWebRequester; resourceWebRequesterWaitingQueue.Enqueue(resourceWebRequester); return(true); }
protected void AddAssetBundleCat(AssetBundleCat assetBundle) { assetBundleCatDict[assetBundle.assetBundleName] = assetBundle; }
public void Init(AssetBundleCat assetBundleCat, string url, bool isNotCache = false) { Init(url, isNotCache); this.assetBundleCat = assetBundleCat; this.assetBundleCat.resourceWebRequester = this; }
protected override void _Destroy() { base._Destroy(); assetBundleName = null; assetBundleCat = null; }