Exemplo n.º 1
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);
        }