public static void LoadAsync(string abName, Action <AssetBundle> callback) { if (string.IsNullOrEmpty(abName)) { Debug.LogError("abName or assetName is null!!!"); if (callback != null) { callback(null); } return; } Action <AssetLoadData> tCallBack = null; if (callback != null) { tCallBack = (data) => { callback(data.mAsset as AssetBundle); }; } HAssetBundle res = Get <HAssetBundle>(abName, "", AssetType.eAB); res.StartLoad(false, false, false, tCallBack); }
public void AddDepRef() { for (int i = 0; i < DepList.Count; i++) { if (mResMap.ContainsKey(DepList[i])) { HAssetBundle res = mResMap[DepList[i]] as HAssetBundle; res.OnAddRef(); } } }
public static AssetBundle Load(string abName) { if (string.IsNullOrEmpty(abName)) { Debug.LogError("abName or assetName is null!!!"); return(null); } HAssetBundle res = Get <HAssetBundle>(abName, "", AssetType.eAB); res.StartLoad(true, false, false, null); return(res.AssetData.mAsset as AssetBundle); }
public override void Release() { //减少自身 OnRelease(); //减少依赖 for (int i = 0; i < DepList.Count; i++) { if (mResMap.ContainsKey(DepList[i])) { HAssetBundle res = mResMap[DepList[i]] as HAssetBundle; res.OnRelease(); } } }
public void ReleaseAll() { List <HRes> resList = new List <HRes>(); foreach (var item in HRes.mResMap) { resList.Add(item.Value); } //停止掉正在加载的AB ABRequest.StopAllRequest(); //停止掉正在加载的AB中的资源 AssetRequest.StopAllRequest(); //释放AB资源 for (int i = 0; i < resList.Count; i++) { resList[i].ReleaseAll(); } HAssetBundle.ReleaseAssetBundleManifest(); }
//同步加载AB public AssetBundle LoadAB(string abName) { return(HAssetBundle.Load(abName)); }
//协程加载AB public AsyncRequest LoadABRequest(string abName) { return(HAssetBundle.LoadAsync(abName)); }
//异步加载AB public void LoadABAsync(string abName, Action <AssetBundle> callback) { HAssetBundle.LoadAsync(abName, callback); }