Пример #1
0
        /// <summary>
        /// 初始化资源打包配置
        /// </summary>
        /// <param name="target">目标平台</param>
        public void InitResourcePacker(BuildTarget target)
        {
            JW.Common.Log.LogD("------------->初始化打包配置:" + GetPlatformStr(target) + "<-------------");
            AssetDatabase.Refresh();
            //打包配置解析
            _packConfig = new ResBuildConfig(_buildCfgXML, _outCfgFileName);
            bool isOk = _packConfig.Parse(target, true);

            if (isOk == false)
            {
                Terminate("打包配置初始化错误");
                return;
            }
            JW.Common.Log.LogD("------------->Done!<-------------");
        }
Пример #2
0
        /// 删除多余的Resource 目录资源
        public void DeleteRedundantFiles(BuildTarget target)
        {
            if (_packConfig == null)
            {
                _packConfig = new ResBuildConfig(_buildCfgXML, _outCfgFileName);
                bool isOK = _packConfig.Parse(target, true);
                if (isOK == false)
                {
                    _packConfig = null;
                    Terminate("解析打包build 错误");
                    return;
                }
            }
            //TODO 去掉打包的场景  目前无用
            // 删除
            Action <string> Delete = (string path) =>
            {
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }
                // asset
                if (File.Exists(path))
                {
                    try
                    {
                        File.Delete(path);
                    }
                    catch (Exception e)
                    {
                        Terminate("Deleting assets failed, error:" + e.Message);
                    }
                }

                // meta
                if (File.Exists(path + ".meta"))
                {
                    try
                    {
                        File.Delete(path + ".meta");
                    }
                    catch (Exception e)
                    {
                        Terminate("Deleting assets failed, error:" + e.Message);
                    }
                }
            };

            //配置定义要删除的
            foreach (string asset in _packConfig.DeleteAssets)
            {
                Delete(asset);
            }

            //删除Resource 下面打包好的资源
            foreach (ResPackInfo pi in _packConfig.PackInfoAll)
            {
                if (pi is BundlePackInfo)
                {
                    BundlePackInfo bpi = pi as BundlePackInfo;
                    if (bpi != null && bpi.IsNoBundle())
                    {
                        continue;
                    }
                }
                //
                foreach (ResInfo res in pi.Resources)
                {
                    if (res.Keep)
                    {
                        continue;
                    }
                    Delete(res.RelativePath);
                }
            }
        }