/// <summary> /// 延迟卸载,每帧检查 /// </summary> void DeferUnloadUpdate() { JWObjList <string> unloaded = null; var itor = _unloadingBundle.GetEnumerator(); while (itor.MoveNext()) { if (itor.Current.Value.Frame < 0) { if (unloaded == null) { unloaded = new JWObjList <string>(); } unloaded.Add(itor.Current.Key); DeferUnloadData.Recycle(itor.Current.Value); } else { itor.Current.Value.Frame--; } } for (int i = 0; unloaded != null && i < unloaded.Count; i++) { UnloadImmediately(unloaded[i]); _unloadingBundle.Remove(unloaded[i]); } }
/// 初始化 public void Initialize() { if (_isInitialized) { return; } //记录默认显示的优先级 _defaultShowPriority = ShowPriority; _isInitialized = true; //初始化UI组件 UIComponent[] ccs = new UIComponent[100]; int ccCnt = 0; UIUtility.GetComponentsInChildren <UIComponent>(gameObject, ccs, ref ccCnt); if (ccs != null && ccCnt > 0) { if (_uiComponents == null) { _uiComponents = new JWObjList <UIComponent>(); } for (int i = 0; i < ccCnt; i++) { ccs[i].Initialize(this); //Cache _uiComponents.Add(ccs[i]); } } }
/// <summary> /// 加载常驻bundle /// </summary> /// <param name="complete"></param> /// <param name="progress"></param> /// <returns></returns> public IEnumerator LoadResidentBundles(Action complete = null, BundleBatchLoadingDelegate progress = null) { ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { JW.Common.Log.LogE("In LoadResidentBundles(), but ResPackConfig is null."); if (complete != null) { complete(); } yield break; } JWObjList <BundlePackInfo> bundleList = new JWObjList <BundlePackInfo>(); for (int i = 0; i < config.PackInfo.Count; i++) { BundlePackInfo p = config.PackInfo[i] as BundlePackInfo; if (p != null && p.Life == EBundleLife.Resident) { bundleList.Add(p); } } yield return(StartCoroutine(BundleService.GetInstance().BatchLoadAsync(bundleList, complete, progress))); }
public int BundleCount(JWObjList <string> resourceList) { ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { return(0); } JWObjList <BundlePackInfo> bundles = GetBundleList(resourceList); if (bundles == null) { return(0); } int count = 0; for (int i = 0; i < bundles.Count; i++) { // 非NoBundle资源,或者在磁盘上有这个bundle BundlePackInfo bpi = bundles[i]; //if (!bpi.IsNoBundle()) //{ // count++; //} } return(count); }
/// <summary> /// 反初始化 /// </summary> public override void Uninitialize() { if (_forms != null) { //清理 for (int i = 0; i < _forms.Count; i++) { UIForm cur = _forms[i]; if (cur != null) { //转为关闭状态 if (cur.TurnToClosed(true)) { cur.OnRemove(); _forms[i] = null; } } } _forms.Clear(); _forms = null; } _formOpenOrder = 1; _formSequence = 0; sUGUIFrameCount = 0; if (_uiRoot != null) { GameObject.Destroy(_uiRoot); _uiRoot = null; } _formCamera = null; _uiInputEventSystem = null; }
/// <summary> /// 初始化 /// </summary> public void Initialize(LuaEnv lua) { _eventDataCache = new CircleBuffer <EventData>(100); _eventData = new JWObjList <EventData>(); _onUIEvent = lua.Global.GetInPath <OnUIEventDelegate>("EventService.OnUIEvent"); _onUIEventListener = lua.Global.GetInPath <OnUIEventListnerDelegate>("EventService.OnUIEventListener"); }
/// <summary> /// 执行Resources.UnloadUnusedAssets,GC.Collect /// </summary> /// <param name="willUseAssets">这些资源在加载过程中或者即将加载,不能卸载他们的bundle</param> public void UnloadUnusedAssets(JWObjList <string> willUseAssets = null) { _resCache.UnloadUnusedResources(willUseAssets); BundleService.GetInstance().UnloadUnusedBundles(willUseAssets); ExtResources.UnloadUnusedAssets(); System.GC.Collect(); }
public bool Initialize() { _loadingResources = new JWObjList <string>(); _unbundledResources = new JWObjList <string>(); _relatedResources = new JWObjList <string>(); _sInstance = this; return(true); }
public void LoadBundleSync(JWObjList <string> resourceList) { JWObjList <BundlePackInfo> bundles = GetBundleList(resourceList); if (bundles == null || bundles.Count == 0) { return; } BundleService.GetInstance().LoadSync(bundles[0]); }
/// <summary> /// 根据资源列表取bundle列表 /// </summary> /// <param name="resourceList"></param> /// <param name="recordResources"></param> public JWObjList <BundlePackInfo> GetBundlePackInfoListForResources(JWObjList <string> resourceList, bool recordResources) { if (resourceList == null || resourceList.Count == 0) { return(null); } ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { if (recordResources) { _unbundledResources.AddRange(resourceList); } return(null); } JWObjList <BundlePackInfo> bundleList = null; for (int i = 0; i < resourceList.Count; i++) { string path = resourceList[i]; BundlePackInfo info = config.GetPackInfoForResource(JW.Res.FileUtil.EraseExtension(path)) as BundlePackInfo; if (info != null) { if (bundleList == null) { bundleList = new JWObjList <BundlePackInfo>(); } if (!bundleList.Contains(info)) { bundleList.Add(info); } // bundle正在加载中的资源 if (recordResources && !_loadingResources.Contains(path)) { _loadingResources.Add(path); } } else { if (recordResources && !_unbundledResources.Contains(path)) { _unbundledResources.Add(path); } } } return(bundleList); }
public void Uninitialize() { StopAllCoroutines(); _loadingResources.Clear(); _loadingResources = null; _unbundledResources.Clear(); _unbundledResources = null; _relatedResources.Clear(); _relatedResources = null; _sInstance = null; }
//反初始化 public void UnInit() { if (m_kAudioList != null) { for (int i = 0; i < m_kAudioList.Count; i++) { Audio audio = m_kAudioList[i]; audio.UnInit(); } m_kAudioList.Clear(); m_kAudioList = null; } }
void OnDestroy() { EventHandler = null; _isInitialized = false; if (_uiComponents != null) { _uiComponents.Clear(); _uiComponents = null; } _fadeInAnimationCtr = null; _fadeOutAnimationCtr = null; Controller = null; }
/// <summary> /// 初始化 /// </summary> /// <returns>初始化成功/失败</returns> public override bool Initialize() { _forms = new JWObjList <UIForm>(); _formOpenOrder = 1; _formSequence = 0; sUGUIFrameCount = 0; //创建UIRoot CreateUIRoot(); //创建EventSystem CreateEventSystem(); //创建Camera CreateCamera(); return(true); }
/// <summary> /// 真正卸载无用bundle /// </summary> public void UnloadUnusedBundles(JWObjList <string> willUseAssets = null) { JWObjList <string> unloaded = null; var itor = _bundleDict.GetEnumerator(); while (itor.MoveNext()) { BundleRef br = itor.Current.Value; if (br.RefCnt <= 0 && !_loadingBundle.Contains(br.Path)) { // bundle对应的资源可能还会被用到,暂时不卸载 if (willUseAssets != null && willUseAssets.Count > 0 && br.PackInfo != null) { for (int i = 0; i < willUseAssets.Count; i++) { string asset = willUseAssets[i]; if (br.PackInfo.Contains(asset)) { continue; } } } if (unloaded == null) { unloaded = new JWObjList <string>(); } unloaded.Add(br.Path); if (br.Bundle != null) { br.Bundle.Unload(false); } // depencency for (int i = 0; br.PackInfo.Dependencies != null && i < br.PackInfo.Dependencies.Count; i++) { Unload(br.PackInfo.Dependencies[i]); } } } for (int i = 0; unloaded != null && i < unloaded.Count; i++) { _bundleDict.Remove(unloaded[i]); } }
/// 游戏更新检查后后启动 public void StartAfterUpdate(Action <bool> allCompletedCallback) { _allCompletedCallback = allCompletedCallback; #if USE_PACK_RES if (ResService.GetInstance().PackConfig == null) { JW.Common.Log.LogE("Preloader.StartAfterUpdate : resource initialize failed"); return; } // _bundleFiles = BundleMediator.GetInstance().GetPreloadBundles(); _bundleLoading = false; string filename = "main_shaders.ab"; _shaderBundle = BundleService.GetInstance().GetBundle(filename); if (_shaderBundle == null) { JW.Common.Log.LogE("Preloader.StartAfterUpdate : failed to get shader bundle"); } ResPackInfo pi = ResService.GetInstance().PackConfig.GetPackInfo(filename); if (pi == null) { _shaderFilename = new JWArrayList <string>(0); } else { _shaderFilename = new JWArrayList <string>(pi.Resources.Count); for (int i = 0; i < pi.Resources.Count; i++) { _shaderFilename.Add(pi.Resources[i].Path); } } #else _bundleFiles = new JWObjList <string>(0); _shaderBundle = null; _shaderFilename = new JWArrayList <string>(0); #endif //真正的开始预加载协成 StartCoroutine(PreloadCoroutine()); }
/// <summary> /// 异步Bundle加载完成回调 /// </summary> /// <param name="resourcePath"></param> /// <param name="succeed"></param> private void OnBundleLoadCompleted(JWObjList <string> resourcePath, bool succeed) { if (resourcePath == null || resourcePath.Count == 0) { JW.Common.Log.LogE("Loader.OnBundleLoadCompleted : invalid parameter"); return; } for (int i = 0; i < _resourceRequesting.Count; i++) { LoadData loadData = _resourceRequesting[i]; if (loadData.LoadBundleState != LoadStateLoading || !resourcePath.Contains(loadData.Data.Filename)) { continue; } loadData.LoadBundleState = succeed ? LoadStateSuccess : LoadStateFail; _resourceRequesting[i] = loadData; } }
/// <summary> /// 反初始化 /// </summary> public void UnInitialize() { if (_eventData != null) { for (int i = 0; i < _eventData.Count; i++) { if (_eventData[i].ID > 0) { JW.Common.Log.LogE("LuaEvent.Uninitialize error : event data is not empty"); _eventData[i].Destroy(null); } } _eventData.Clear(); _eventData = null; } if (_eventDataCache != null) { _eventDataCache.Clear(); _eventDataCache = null; } _onUIEvent = null; }
/// <summary> /// 卸载资源列表对应bundle /// </summary> /// <param name="resourcesPath"></param> public void UnloadBundle(JWObjList <string> resourcesPath) { JWObjList <BundlePackInfo> bundleList = GetBundlePackInfoListForResources(resourcesPath, false); if (bundleList != null && bundleList.Count > 0) { for (int i = 0; i < bundleList.Count; i++) { BundlePackInfo packInfo = bundleList[i]; // unity场景 if (packInfo.HasFlag(EBundleFlag.UnityScene)) { BundleService.GetInstance().OnAssetLoaded(packInfo); } else { BundleService.GetInstance().Unload(bundleList[i]); } } } }
/// <summary> /// 获取预加载bundle列表 /// </summary> /// <returns></returns> public JWObjList <string> GetPreloadBundles() { JWObjList <string> bundleList = new JWObjList <string>(); ResPackConfig config = ResService.GetInstance().PackConfig; for (int i = 0; i < config.PackInfo.Count; i++) { BundlePackInfo p = config.PackInfo[i] as BundlePackInfo; if (p == null) { continue; } if (p.HasFlag(EBundleFlag.PreLoad)) { bundleList.Add(p.Path); } } return(bundleList); }
/// <summary> /// 卸载资源 /// </summary> public void UnloadUnusedResources(JWObjList <string> willUseAssets = null) { JWObjList <string> unloaded = null; var itor = _resources.GetEnumerator(); while (itor.MoveNext()) { if (itor.Current.Value.RefCnt <= 0) { if (willUseAssets != null && willUseAssets.Contains(itor.Current.Key)) { willUseAssets.Remove(itor.Current.Key); continue; } if (unloaded == null) { unloaded = new JWObjList <string>(); } unloaded.Add(itor.Current.Key); // unload itor.Current.Value.Unload(); // recycle ResObj instance 回池 ResObj.Recycle(itor.Current.Value); } } for (int i = 0; unloaded != null && i < unloaded.Count; i++) { _resources.Remove(unloaded[i]); } }
JWObjList <BundlePackInfo> GetBundleList(JWObjList <string> resources) { ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { return(null); } JWObjList <BundlePackInfo> bundles = null; for (int i = 0; i < resources.Count; i++) { string path = resources[i]; if (ResService.GetInstance().Exists(path)) { continue; } BundlePackInfo bpi = config.GetPackInfoForResource(path) as BundlePackInfo; if (bpi != null) { if (bundles == null) { bundles = new JWObjList <BundlePackInfo>(); } if (!bundles.Contains(bpi)) { bundles.Add(bpi); } } } return(bundles); }
/// <summary> /// 加载状态相关bundle /// </summary> /// <param name="resourceList">资源路径列表</param> /// <param name="complete">加载完成回调</param> /// <param name="progress">加载进度回调</param> /// <param name="loaded">单个bundle加载完成回调</param> /// <param name="singleSync">true:当只有一个bundle时,使用同步加载;否则使用并发异步加载</param> /// <returns></returns> public IEnumerator LoadBundle(JWObjList <string> resourceList, Action complete = null, BundleBatchLoadingDelegate progress = null, BundleLoadedOneDelegate loaded = null, bool singleSync = true) { bool record = loaded != null; // 剔除已有资源 for (int i = 0; i < resourceList.Count;) { string path = resourceList[i]; if (ResService.GetInstance().Exists(path)) { if (record) { _unbundledResources.Add(path); } resourceList.RemoveAt(i); continue; } i++; } // bundle list JWObjList <BundlePackInfo> bundleList = GetBundlePackInfoListForResources(resourceList, record); // 异步返回,在处理完源数据之后避免resourceList被reset yield return(null); // 未打包资源 if (_unbundledResources.Count > 0) { if (loaded != null) { loaded(_unbundledResources, true); } _unbundledResources.Clear(); } // load if (bundleList != null && bundleList.Count > 0) { if (singleSync && bundleList.Count == 1) { // 只有一个bundle,使用同步加载方式 BundleService.GetInstance().LoadSync(bundleList[0]); if (progress != null) { progress(1f); } if (loaded != null) { AssetBundle bundle = BundleService.GetInstance().GetBundle(bundleList[0].Path); JWObjList <string> relatedResources = GetLoadedBundleResources(bundleList[0].Path); if (relatedResources != null && relatedResources.Count > 0) { loaded(relatedResources, bundle != null); relatedResources.Clear(); } BundleService.GetInstance().Unload(bundleList[0]); } if (complete != null) { complete(); } } else { // 多个bundle,使用并发加载 yield return(StartCoroutine(BundleService.GetInstance().BatchLoadAsync(bundleList, delegate() { if (complete != null) { complete(); } }, progress, delegate(BundleRef bundle) { if (bundle != null) { if (loaded != null) { JWObjList <string> relatedResources = GetLoadedBundleResources(bundle.Path); if (relatedResources != null && relatedResources.Count > 0) { loaded(relatedResources, true); relatedResources.Clear(); } BundleService.GetInstance().Unload(bundle.PackInfo); } } }, delegate(BundlePackInfo pi, string error) { if (loaded != null) { JWObjList <string> relatedResources = GetLoadedBundleResources(pi.Path); if (relatedResources != null && relatedResources.Count > 0) { //bool succ = (pi.IsNoBundle()); //loaded(relatedResources, succ); //relatedResources.Clear(); } } }))); } } else { if (complete != null) { complete(); } } }
public IEnumerator BatchLoadAsync(JWObjList <BundlePackInfo>[] bundleLists, Action complete, BundleBatchLoadingDelegate progress = null) { if (bundleLists == null || bundleLists.Length == 0) { if (progress != null) { progress(1f); } if (complete != null) { complete(); } yield break; } int totalBundles = 0; for (int i = 0; i < bundleLists.Length; ++i) { JWObjList <BundlePackInfo> bundles = bundleLists[i]; if (bundles != null) { for (int j = 0; j < bundles.Count; ++j) { if (bundles[j] != null) { ++totalBundles; } } } } // 并发加载多个bundle JWObjList <string> failedBundles = null; Dictionary <string, float> progressDict = new Dictionary <string, float>(totalBundles); // 因为是并发,所以计算进度稍微复杂一些,需要每个bundle的进度收集计算 float step = 1f / totalBundles; // 大致平分每个bundle的加载时间 for (int i = 0; i < bundleLists.Length; ++i) { JWObjList <BundlePackInfo> bundles = bundleLists[i]; StartCoroutine(LoadAsync(bundles, delegate(BundleRef bundleRef) { // complete one if (bundleRef != null) { // 已加载完成某一个bundle if (progressDict.ContainsKey(bundleRef.Path)) { progressDict[bundleRef.Path] = 1f; } else { progressDict.Add(bundleRef.Path, 1f); } } }, delegate(BundlePackInfo packInfo, string error) { if (failedBundles == null) { failedBundles = new JWObjList <string>(); } if (!failedBundles.Contains(packInfo.Path)) { failedBundles.Add(packInfo.Path); } }, delegate(BundlePackInfo packInfo, float prog) { // 加载进度回调,会有多次 if (progress != null) { // 记录每次每个bundle的进度 if (progressDict.ContainsKey(packInfo.Path)) { progressDict[packInfo.Path] = prog; } else { progressDict.Add(packInfo.Path, prog); } // 计算总进度 float totalProgress = 0; for (int bundleListIndex = 0; bundleListIndex < bundleLists.Length; ++bundleListIndex) { JWObjList <BundlePackInfo> bundlePackInfos = bundleLists[bundleListIndex]; if (bundlePackInfos != null) { for (int bundleIndex = 0; bundleIndex < bundlePackInfos.Count; ++bundleIndex) { if (bundlePackInfos[bundleIndex] != null) { float eachProg = 0; if (progressDict.TryGetValue(bundlePackInfos[bundleIndex].Path, out eachProg)) { totalProgress += eachProg * step; } } } } } progress(totalProgress); } })); } // 检查是否全部完成 while (true) { bool completed = true; for (int bundleListIndex = 0; bundleListIndex < bundleLists.Length; ++bundleListIndex) { JWObjList <BundlePackInfo> bundlePackInfos = bundleLists[bundleListIndex]; if (bundlePackInfos != null) { for (int bundleIndex = 0; bundleIndex < bundlePackInfos.Count; ++bundleIndex) { BundlePackInfo bundleInfo = bundlePackInfos[bundleIndex]; if (_bundleDict.ContainsKey(bundleInfo.Path)) { continue; } if (failedBundles != null && failedBundles.Contains(bundleInfo.Path)) { continue; } completed = false; yield return(null); break; } } if (!completed) { break; } } if (completed) { if (complete != null) { complete(); } yield break; } } }
/// <summary> /// 异步加载bundle列表 /// </summary> /// <param name="packInfo">bundle打包信息</param> /// <param name="complete">加载完成回调</param> /// <param name="failure">加载失败回调</param> /// <param name="loading">加载进度回调</param> /// <returns></returns> public IEnumerator LoadAsync(JWObjList <BundlePackInfo> packInfos, BundleLoadedDelegate complete, BundleLoadFailedDelegate failure, BundleLoadingDelegate loading = null) { if (packInfos == null) { JW.Common.Log.LogE("Async loading bundle with null pack info."); yield break; } //JWObjList<BundleRef> bundleRefs = new JWObjList<BundleRef>(); for (int i = 0; i < packInfos.Count; ++i) { BundlePackInfo packInfo = packInfos[i]; if (packInfo != null) { // ab has been loaded BundleRef br = null; if (_bundleDict.TryGetValue(packInfo.Path, out br)) { br.RefCnt++; if (_unloadingBundle.ContainsKey(packInfo.Path)) { _unloadingBundle.Remove(packInfo.Path); } if (loading != null) { loading(packInfo, 1f); } if (complete != null) { complete(br); } continue; } // loading if (_loadingBundle.Contains(packInfo.Path)) { yield return(null); while (_loadingBundle.Contains(packInfo.Path)) { yield return(null); } if (_bundleDict.TryGetValue(packInfo.Path, out br)) { br.RefCnt++; if (complete != null) { complete(br); } } continue; } if (packInfo.HasFlag(EBundleFlag.UnCompress) || packInfo.HasFlag(EBundleFlag.LZ4)) { LoadSync(packInfo); yield break; } //LZMA // 放在加载依赖前,因为加载依赖表示已经开始加载了 _loadingBundle.Add(packInfo.Path); // dependency for (int j = 0; packInfo.Dependencies != null && j < packInfo.Dependencies.Count; j++) { yield return(StartCoroutine(LoadAsync(packInfo.Dependencies[j], null, null))); } // no bundle if (packInfo.IsNoBundle() && !packInfo.Outside) { _loadingBundle.Remove(packInfo.Path); yield break; } // load string path = GetBundleFullPath(packInfo, true); JW.Common.Log.LogD("Async load bundle liat path:{0}", path); UnityWebRequest www = null; www = UnityWebRequest.GetAssetBundle(path); yield return(www.SendWebRequest()); // loading progress if (loading != null) { float progress = 0.0f; while (string.IsNullOrEmpty(www.error) && !www.isDone) { if (www.downloadProgress < 0.00001 && www.downloadProgress > -0.00001) { progress += 0.01f; loading(packInfo, progress); } else { loading(packInfo, www.downloadProgress); } yield return(null); } if (string.IsNullOrEmpty(www.error)) { loading(packInfo, 1f); } } _loadingBundle.Remove(packInfo.Path); // failed if (!string.IsNullOrEmpty(www.error)) { JW.Common.Log.LogE("Async loading bundle {0} failed, error:{1}", packInfo.Path, www.error); if (failure != null) { failure(packInfo, www.error); } www.Dispose(); continue; } AssetBundle ab = DownloadHandlerAssetBundle.GetContent(www); // succeed if (ab != null) { br = new BundleRef(packInfo); br.Bundle = ab; _bundleDict.Add(packInfo.Path, br); if (complete != null) { complete(br); } } www.Dispose(); } } }
private IEnumerator AsynchronousLoad() { JWObjList <string> stringList = new JWObjList <string>(); JWArrayList <AssetData> assetDataList = new JWArrayList <AssetData>(); IEnumerator loadBundleEnumerator = AsynchronousLoad_LoadAssetBundle(stringList, assetDataList); IEnumerator loadResourceEnumerator = AsynchronousLoad_LoadResource(); IEnumerator instantiateEnumerator = AsynchronousLoad_InstantiateResource(); if (loadBundleEnumerator == null || loadResourceEnumerator == null || instantiateEnumerator == null) { yield break; } while (true) { yield return(null); if (_synLoading) { continue; } while (_resourceDiscardRequest != null) { if (!_resourceDiscardRequest.isDone) { yield return(null); continue; } if (_resourceDiscardRequest.resource != null) { ResService.UnloadResource(_resourceDiscardRequest.resource); } _resourceDiscardRequest = null; yield return(null); } if (_resourceRequesting.Count > 0) { while (instantiateEnumerator.MoveNext()) { if (instantiateEnumerator.Current == InstructionEnd) { break; } yield return(null); } } if (_resourceRequesting.Count > 0) { while (loadResourceEnumerator.MoveNext()) { if (loadResourceEnumerator.Current == InstructionEnd) { break; } yield return(null); } } _loadAssetBundlePriority = AsynchronousLoad_CalculatePriority(); if (_loadAssetBundlePriority != int.MaxValue && (_loadAssetBundlePriority < LoadPriority.Preprocess || (!BundleService.GetInstance().IsWorking() && _resourceDiscardRequest == null && _resourceRequesting.Count == 0))) { while (loadBundleEnumerator.MoveNext()) { if (loadBundleEnumerator.Current == InstructionEnd) { break; } yield return(null); } } } }
private IEnumerator AsynchronousLoad_LoadAssetBundle(JWObjList <string> stringList, JWArrayList <AssetData> assetDataList) { while (true) { stringList.Clear(); assetDataList.Clear(); for (int i = 0; i < _data.Count;) { AssetData data = _data[i]; if (data.Priority != _loadAssetBundlePriority) { ++i; continue; } _data.RemoveAt(i); if (_assetManager.GetCacheCount(data.Name) >= data.Count) { if (data.Callback != null) { assetDataList.Add(data); } continue; } LoadData loadData; loadData.Data = data; loadData.LoadBundleState = LoadStateLoading; loadData.Request = null; bool insert = false; for (int j = _resourceRequesting.Count - 1; j >= 0; --j) { if (_resourceRequesting[j].Data.Priority <= data.Priority) { _resourceRequesting.Insert(j + 1, loadData); insert = true; break; } } if (!insert) { _resourceRequesting.Insert(0, loadData); } stringList.Add(data.Filename); if (_loadAssetBundlePriority >= LoadPriority.Preprocess) { break; } } yield return(null); if (stringList.Count > 0) { #if USE_PACK_RES BundleMediator.GetInstance().LoadBundle(stringList, OnBundleLoadCompleted); #else OnBundleLoadCompleted(stringList, true); #endif } yield return(null); for (int i = 0; i < assetDataList.Count; i++) { AssetData data = assetDataList[i]; if (data.Callback != null) { data.Callback.OnLoadAssetCompleted(data.Name, AssetLoadResult.Success, null); yield return(null); } } yield return(InstructionEnd); } }
/// <summary> /// 加载资源相关bundle /// </summary> /// <param name="resourcesPath">资源路径列表</param> /// <param name="loaded">单个资源加载完成</param> /// <returns></returns> public void LoadBundle(JWObjList <string> resourcesPath, BundleLoadedOneDelegate loaded = null) { StartCoroutine(LoadBundle(resourcesPath, null, null, loaded, false)); }