/// <summary> /// 某个BundleGroup是否下载 /// </summary> /// <param name="groupName"></param> /// <returns></returns> public bool IsBundleGroupLoaded(string groupName) { AssetBundleGroupLoadHelperItem assetBundleGroupLoadHelperItem = GetAssetBundleGroupLoadHelperItem(groupName); if (assetBundleGroupLoadHelperItem != null) { return(assetBundleGroupLoadHelperItem.IsLoaded); } return(false); }
/// <summary> /// 下载 某个BundleGroup /// </summary> /// <param name="groupName"></param> /// <param name="quietDownLoad"></param> /// <returns></returns> public ProgressInfo LoadBundleGroup(string groupName, bool quietDownLoad = false) { AssetBundleGroupLoadHelperItem assetBundleGroupLoadHelperItem = GetAssetBundleGroupLoadHelperItem(groupName); if (assetBundleGroupLoadHelperItem != null) { return(assetBundleGroupLoadHelperItem.Load(assetUrl, quietDownLoad)); } return(null); }
/// <summary> /// 暂停下载 /// </summary> public void Pause() { if (_initQuietLoad && curAssetBundleGroupLoadHelper != null) { curAssetBundleGroupLoadHelper.Pause(); curAssetBundleGroupLoadHelper = null; quietDownLoadInfo.loadingStatus = LoadingStatus.Pause; EventDispatcher.TriggerEvent(EventKey.QuietLoadStatusChanged); } }
public static AssetBundleGroupLoadHelperItem Create(string _groupName, AssetBundleGroupInfo _assetBundleGroupInfo) { GameObject gameObject = new GameObject(); gameObject.transform.SetParent(AssetBundleManager.Instance.transform); AssetBundleGroupLoadHelperItem helper = gameObject.AddComponent <AssetBundleGroupLoadHelperItem>(); helper.Init(_groupName, _assetBundleGroupInfo); return(helper); }
public AssetBundleGroupLoadHelperItem GetAssetBundleGroupLoadHelperItem(string groupName) { if (!assetBundleGroupLoadHelpers.ContainsKey(groupName)) { if (!_versionInfo.ContainGroup(groupName)) { return(null); } AssetBundleGroupLoadHelperItem assetBundleGroupLoadHelperItem = AssetBundleGroupLoadHelperItem.Create(groupName, _versionInfo.GetGroup(groupName)); assetBundleGroupLoadHelpers[groupName] = assetBundleGroupLoadHelperItem; } return(assetBundleGroupLoadHelpers[groupName]); }
private void OnAssetBundleLoadSucess(string groupName) { if (_mustLoadGroupNames.Contains(groupName)) { _mustLoadGroupNames.Remove(groupName); quietDownLoadInfo.curMustLoadIndex++; } if (_preLoadGroupNames.Contains(groupName)) { _preLoadGroupNames.Remove(groupName); quietDownLoadInfo.curPreLoadIndex++; } curAssetBundleGroupLoadHelper = null; QuietLoad(); }
private void QuietLoad() { quietDownLoadInfo.loadingStatus = LoadingStatus.Loading; //_mustLoadGroupNames = AssetBundleManager.Inst.GetNotBaseGroupNames(); if (!_finishMustLoad && _mustLoadGroupNames.Count <= 0) { _finishMustLoad = true; EventDispatcher.TriggerEvent(EventKey.QuietLoadMustSucess);//完成必须下载的 } if (!_finishPreLoad && _preLoadGroupNames.Count <= 0) { _finishPreLoad = true; EventDispatcher.TriggerEvent(EventKey.QuietLoadPreSucess);//完成预下载的 } if (_mustLoadGroupNames.Count <= 0 && _preLoadGroupNames.Count <= 0) { _finishLoad = true; quietDownLoadInfo.loadingStatus = LoadingStatus.Finish; EventDispatcher.TriggerEvent(EventKey.QuietLoadAllSucess);//完成全部静默下载 } //必下载的 for (int i = 0; i < _mustLoadGroupNames.Count; i++) { if (!AssetBundleManager.Inst.IsBundleGroupLoaded(_mustLoadGroupNames[i])) { DebugUtil.Log("QuietDownLoadManager : start load {0}", _mustLoadGroupNames[i]); AssetBundleManager.Inst.LoadBundleGroup(_mustLoadGroupNames[i], true); curAssetBundleGroupLoadHelper = AssetBundleManager.Inst.GetAssetBundleGroupLoadHelperItem(_mustLoadGroupNames[i]); return; } } //预下载的 for (int i = 0; i < _preLoadGroupNames.Count; i++) { if (!AssetBundleManager.Inst.IsBundleGroupLoaded(_preLoadGroupNames[i])) { DebugUtil.Log("QuietDownLoadManager : start load {0}", _preLoadGroupNames[i]); AssetBundleManager.Inst.LoadBundleGroup(_preLoadGroupNames[i], true); curAssetBundleGroupLoadHelper = AssetBundleManager.Inst.GetAssetBundleGroupLoadHelperItem(_preLoadGroupNames[i]); return; } } }