public void LoadAsset(AbParam abParam, Action <string, UnityEngine.Object> finish) { AssetBundleMgr.Instance.LoadAssetBundlePack(abParam.SceneName, abParam.AbName, (p) => { UnityEngine.Object asset = AssetBundleMgr.Instance.LoadAsset(abParam.SceneName, abParam.AbName, abParam.AssetName); if (asset == null) { finish("load assetBundel errro!", null); } else { finish(null, asset); } }); }
private IEnumerator LoadAssetBundlePackAsyn(string sceneName, string abName, DelLoadComplete loadAllCompleteHandle) { AbInfo abInfo = null; //等待Manifest文件加载完成 while (!ABManifestLoader.Instance.IsLoadFinish) { yield return(null); } manifestObj = ABManifestLoader.Instance.GetABManifest(); if (manifestObj == null) { Debug.LogError(GetType() + "/LoadAssetBundlePack()/manifestObj is Null!"); yield break; } abName = abName.ToLower();//将名字转换成小写 if (dicAbCach.ContainsKey(abName)) { dicAbCach.TryGetValue(abName, out abInfo); if (abInfo.AbState == EnumAbState.Release) { Debug.Log("资源正在释放!abName:" + abName); yield break; } while (abInfo.AbState == EnumAbState.Loading) { yield return(null); } loadAllCompleteHandle(abName); yield break; } else { abInfo = new AbInfo(); AbParam abParam = new AbParam(); abParam.SceneName = sceneName; abParam.AbName = abName; abInfo.AbParam = abParam; abInfo.AbState = EnumAbState.Loading; dicAbCach.Add(abName, abInfo); } if (!dicAllScenes.ContainsKey(sceneName)) { MultiABMgr multiABMgrObj = new MultiABMgr(sceneName, abName, loadAllCompleteHandle); dicAllScenes.Add(sceneName, multiABMgrObj); } MultiABMgr tmpMultiABMgr = dicAllScenes[sceneName]; if (tmpMultiABMgr == null) { Debug.LogError(GetType() + "/LoadAssetBundlePack()/tmpMultiABMgr is Null!"); } yield return(tmpMultiABMgr.LoadAssetBundle(abName)); abInfo.AbState = EnumAbState.LoadFinish; }
public void LoadAssetBundlePack(AbParam abParam, Action finish) { AssetBundleMgr.Instance.LoadAssetBundlePack(abParam.SceneName, abParam.AbName, (p) => { finish(); }); }