private IEnumerator OnLoadAssetList(PreloadFileModel model, CallBackWithPercent cb) { List <string> list = model.fileList; for (int i = 0; i < list.Count; i++) { string path = list[i]; string bundleName = path.ToLower(); string assetName = path + ".prefab"; AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(bundleName, assetName, typeof(UnityEngine.Object)); if (request != null) { yield return(StartCoroutine(request)); GameObject obj = request.GetAsset <UnityEngine.GameObject>(); _cachePrefabs.Add(bundleName, new ABPrefabInfo(obj)); } else { SampleDebuger.LogError("bundle ++" + bundleName + "++ can't loading"); } cb(i + 1, list.Count); } }
public void LoadAssetList(PreloadFileModel model, CallBackWithPercent cb) { StartCoroutine(OnLoadAssetList(model, cb)); }
/// <summary> /// 预加载游戏 /// </summary> /// <param name="cb">回调:返回读取进度</param> public void PreloadAsset(CallBackWithPercent cb) { PreloadFileModel preloadModel = FileUtil.ReadJsonFromFile <PreloadFileModel>("Config/PreloadAB.json"); _longTermAssetPool.LoadAssetList(preloadModel, cb); }