/// <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> /// 获取bundle打包信息 /// </summary> /// <param name="path">bundle路径</param> /// <returns></returns> BundlePackInfo GetPackInfo(string path) { ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { return(null); } return(config.GetPackInfo(path) as BundlePackInfo); }
/// <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); }
/// <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> /// 获取已加载的bundle对应的资源 /// </summary> /// <param name="bundlePath"></param> /// <returns></returns> public JWObjList <string> GetLoadedBundleResources(string bundlePath) { if (string.IsNullOrEmpty(bundlePath) || _loadingResources.Count == 0) { return(null); } ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { return(null); } BundlePackInfo pi = config.GetPackInfo(bundlePath) as BundlePackInfo; if (pi == null) { return(null); } for (int i = _loadingResources.Count - 1; i >= 0; i--) { string path = _loadingResources[i]; if (pi.Contains(path)) { if (!_relatedResources.Contains(path)) { _relatedResources.Add(path); } _loadingResources.Remove(path); } } return(_relatedResources); }
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); }
public ResBuildConfig(string xmlPath, string outCfgName) { _xmlPath = xmlPath; _outConfigName = outCfgName; _config = new ResPackConfig(); }
void OnGUI() { if (!BundleService.IsValidate()) { return; } JWObjDictionary <string, BundleRef> bundleDict = BundleService.GetInstance().BundleDict; GUILayout.Space(3f); GUILayout.BeginVertical(); // list title GUILayout.BeginHorizontal("Table Title", GUILayout.MinHeight(20f)); GUILayout.Label("Index", _labelStyle, GUILayout.Width(60f)); GUILayout.Label("RefCnt", _labelStyle, GUILayout.Width(60f)); GUILayout.Label("Tag", _labelStyle, GUILayout.Width(120f)); GUILayout.Label("Name", _labelStyle, GUILayout.Width(60f)); GUILayout.EndHorizontal(); ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { return; } // list mScroll = GUILayout.BeginScrollView(mScroll); int index = 0; foreach (var kv in bundleDict) { BundleRef bundle = kv.Value; BundlePackInfo pi = config.GetPackInfo(bundle.Path) as BundlePackInfo; if (pi == null) { continue; } index++; GUILayout.BeginHorizontal("Table Row", GUILayout.MinHeight(20f)); // index GUILayout.Label(index.ToString(), _labelStyle, GUILayout.Width(60f)); // ref count GUILayout.Label(bundle.RefCnt.ToString(), _labelStyle, GUILayout.Width(60f)); // tag //GUILayout.Label(pi.Tag, _labelStyle, GUILayout.Width(120f)); // path GUILayout.Label(pi.Path, _labelStyle); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.Space(3f); }