private IEnumerator CoLoadAB(HAssetBundle ab) { ABData abData = null; if (!mABDataMap.TryGetValue(ab.ABName, out abData)) { abData = new ABData(); mABDataMap[ab.ABName] = abData; } if (abData.mAB == null) { string url = PathManager.URL(ab.ABName, mAssetType, false); if (mIsSync) { if (abData.mRequest == null) { abData.mAB = AssetBundle.LoadFromFile(url); } else { abData.mAB = abData.mRequest.assetBundle; } } else { if (abData.mRequest == null) { AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(url); abData.mRequest = request; yield return(request); } else { while (!abData.mRequest.isDone) { yield return(null); } } abData.mAB = abData.mRequest.assetBundle; } ab.AB = abData.mAB; } }
public IEnumerator CoLoad(HAssetBundle ab) { if (ab == null) { Debug.LogError("ABRequest HAssetbundle is Null"); yield break; } //引用计数 mABLoadList.Clear(); mABLoadList.Add(ab); for (int i = 0; i < ab.DepList.Count; i++) { HAssetBundle depAB = HRes.Get <HAssetBundle>(ab.DepList[i], "", AssetType.eAB, true); mABLoadList.Add(depAB); } //开启所有加载 for (int i = 0; i < mABLoadList.Count; i++) { ResourceManager.Instance.StartCoroutine(CoLoadAB(mABLoadList[i])); } //等待加载完成 for (int i = 0; i < mABLoadList.Count; i++) { ABData data; if (mABDataMap.TryGetValue(mABLoadList[i].ABName, out data)) { if (data.mRequest != null) { while (!data.mRequest.isDone) { yield return(null); } } } else { Debuger.LogError("ASSET_LOAD", "mABDataMap is not find abname : " + mABLoadList[i].ABName); } } IsComplete = true; }
public void Load(HAssetBundle ab, bool isSync, AssetType assetType) { mAssetType = assetType; mIsSync = isSync; ResourceManager.Instance.StartCoroutine(CoLoad(ab)); }