Example #1
0
        /// <summary>
        /// 核心算法步骤:
        /// 1、获得资源的依赖列表List<string> dependAssetPathList = GetDependAssetPathList(entryPath);
        /// 2、根据节点正则表达式,获得该节点分离出来的资源列表pathSet = ApplyStrategyNode(entryPath, asset, node); pathList = pathSet.ToList()
        /// 3、移除pathList中和之前节点帅选结果相同的部分RemoveFilteredPath(filteredPathSet, pathList);
        /// 4、在dependAssetPathList中移除pathList,RemoveFromDependPathList(dependAssetPathList, pathList);
        /// 5、讲pathList加入筛选资源集合AddToFilteredPathSet(filteredPathSet, pathList);
        /// 6、若资源存在临时创建的副本,用副本替换原资源,对副本打包
        /// </summary>
        /// <param name="entryPath"></param>
        /// <param name="strategy"></param>
        /// <returns></returns>
        public virtual List <List <string> > Process(string entryPath, AssetBuildStrategy strategy)
        {
            Object                asset = GetAsset(entryPath);
            List <string>         dependAssetPathList = GetDependAssetPathList(entryPath);
            List <List <string> > pathListList        = new List <List <string> >();
            HashSet <string>      filteredPathSet     = new HashSet <string>();

            for (int i = 0; i < strategy.nodeList.Count; i++)
            {
                StrategyNode     node = strategy.nodeList[i];
                HashSet <string> pathSet;
                if (string.IsNullOrEmpty(node.processor) == false)
                {
                    pathSet = ApplyStrategyNode(entryPath, asset, node);
                }
                else
                {
                    pathSet = ApplyEmptyStrategyNode(dependAssetPathList, node);
                }
                List <string> pathList = pathSet.ToList();
                RemoveFilteredPath(filteredPathSet, pathList);
                RemoveFromDependPathList(dependAssetPathList, pathList);
                AddToFilteredPathSet(filteredPathSet, pathList);
                ReplaceWithTempAssetPath(pathList);
                pathListList.Add(pathList);
            }
            SaveAssets(asset, entryPath);
            return(pathListList);
        }
Example #2
0
        private static List <List <string> > ProcessAsset(string path)
        {
            AssetBuildStrategy strategy = AssetBuildStrategyManager.GetAssetBuildStrategy(path);

            if (strategy != null)
            {
                return(AssetProcessor.ProcessAsset(path, strategy));
            }
            return(new List <List <string> >());
        }
Example #3
0
        private static bool IsBuildStrategyExists(string entryPath)
        {
            AssetBuildStrategy strategy = AssetBuildStrategyManager.GetAssetBuildStrategy(entryPath, false);

            if (strategy == null)
            {
                Logger.GetLogger(LOGGER_NAME).Log(string.Format("<color=#0000ff>未找到路径 {0} 对应的打包策略配置!</color>", entryPath));
                return(false);
            }
            return(true);
        }
Example #4
0
        public static List <List <string> > ProcessAsset(string entryPath, AssetBuildStrategy strategy)
        {
            string extension = Path.GetExtension(entryPath.ToLower());

            switch (extension)
            {
            case ASSET_PREFAB:
                return(_gameObjectProcessor.Process(entryPath, strategy));

            case ASSET_MATERIAL:
                return(_materialProcessor.Process(entryPath, strategy));

            case ASSET_FONT:
                return(_fontProcessor.Process(entryPath, strategy));
            }
            return(_assetProcessor.Process(entryPath, strategy));
        }
        public static void Initialize()
        {
            Dictionary <BuildTarget, string> buildTargetIdentifierDict = GetBuildTargetIndentifierDict();

            _assetStrategyDict  = new Dictionary <string, AssetBuildStrategy>();
            _defineStrategyDict = new Dictionary <string, AssetBuildStrategy>();
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.PreserveWhitespace = false;
            xmlDoc.Load(AssetPathHelper.ToFileSystemPath(SETTING_PATH));
            XmlNode root = xmlDoc.SelectSingleNode("root");

            outputPath = root.Attributes["output"].Value + buildTargetIdentifierDict[AssetPathHelper.GetBuildTarget()] + "/";
            CreateOutputFolder(outputPath);
            isSaveTemp      = root.Attributes["saveTempFile"].Value.ToLower() == "true";
            isBuild         = root.Attributes["build"].Value.ToLower() == "true";
            isReport        = root.Attributes["report"].Value.ToLower() == "true";
            isSaveUIMediate = root.Attributes["saveUIMediate"].Value.ToLower() == "true";

            foreach (XmlNode node in root.ChildNodes)
            {
                if (!(node is XmlElement))
                {
                    continue;
                }
                AssetBuildStrategy strategy = new AssetBuildStrategy(node);
                if (string.IsNullOrEmpty(strategy.name) == true)
                {
                    throw new Exception("Build strategy name not set " + node.InnerText);
                }
                if (_defineStrategyDict.Keys.Contains(strategy.name))
                {
                    throw new Exception("Duplicated strategy name:" + strategy.name);
                }
                _defineStrategyDict.Add(strategy.name, strategy);
            }
        }