Example #1
0
        public static void RecordAssetDependency(string entryPath, List <string> bundlePathList)
        {
            string key = AssetPathHelper.EliminaterStartToken(entryPath);

            if (_dependentPhysicalPathListDict.ContainsKey(key) == false)
            {
                _dependentPhysicalPathListDict.Add(key, bundlePathList);
                _isRecordDirty = true;
                return;
            }

            List <string> existBundlePathList = _dependentPhysicalPathListDict[key];

            if (existBundlePathList.Count != bundlePathList.Count)
            {
                _dependentPhysicalPathListDict[key] = bundlePathList;
                _isRecordDirty = true;
                return;
            }
            for (int i = 0; i < existBundlePathList.Count; i++)
            {
                if (existBundlePathList[i] != bundlePathList[i])
                {
                    _dependentPhysicalPathListDict[key] = bundlePathList;
                    _isRecordDirty = true;
                    return;
                }
            }
        }
        public static string GetTempAssetPath(string path)
        {
            string tempAssetPath = path.Replace(RESOURCES, RESOURCES_TEMP);
            string folderPath    = Path.GetDirectoryName(AssetPathHelper.ToFileSystemPath(tempAssetPath));

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }
            return(tempAssetPath);
        }
Example #3
0
        public override HashSet <string> Process(string entryPath, GameObject go, StrategyNode node)
        {
            HashSet <string> result = new HashSet <string>();
            Image            image  = go.GetComponent <Image>();

            if (image != null)
            {
                string path = AssetDatabase.GetAssetPath(go);
                if (node.pattern.IsMatch(path))
                {
                    string folderPath = Path.GetDirectoryName(path);
                    image.spriteKey = AssetPathHelper.ReplaceSlash(AssetPathHelper.EliminaterStartToken(folderPath)) + "${0}";
                    result.Add(path);
                }
            }
            return(result);
        }
        public override HashSet <string> Process(string entryPath, GameObject go, StrategyNode node)
        {
            HashSet <string> result = new HashSet <string>();
            Text             text   = go.GetComponent <Text>();

            if (text != null && text.font != null)
            {
                string fontPath = AssetDatabase.GetAssetPath(text.font);
                if (node.pattern.IsMatch(fontPath))
                {
                    text.fontKey = AssetPathHelper.GetObjectKey(entryPath, fontPath, text.font, node);
                    text.font    = null;
                    result.Add(fontPath);
                }
            }
            return(result);
        }
        // TODO 看不懂
        public override HashSet <string> Process(string entryPath, GameObject go, StrategyNode node)
        {
            HashSet <string> result    = new HashSet <string>();
            Animation        animation = go.GetComponent <Animation>();

            if (animation != null)
            {
                AnimationClip[] clips       = AnimationUtility.GetAnimationClips(go);
                AnimationClip   defaultClip = animation.clip;
                VerifyClipsName(entryPath, clips);
                string[] clipTokens = GetClipTokens(go, clips.Length);
                if (defaultClip != null)
                {
                    string defaultClipPath = AssetDatabase.GetAssetPath(defaultClip);
                    if (node.pattern.IsMatch(defaultClipPath))
                    {
                        string defaultClipKey = AssetPathHelper.GetObjectKey(entryPath, defaultClipPath, defaultClip, node);
                        result.Add(defaultClipPath);
                        animation.clip = null;
                        clipTokens[0]  = defaultClipKey;
                    }
                }

                for (int i = 0; i < clips.Length; i++)
                {
                    AnimationClip clip = clips[i];
                    if (clip != null)
                    {
                        string clipPath = AssetDatabase.GetAssetPath(clip);
                        if (node.pattern.IsMatch(clipPath))
                        {
                            string clipKey = AssetPathHelper.GetObjectKey(entryPath, clipPath, clip, node);
                            result.Add(clipPath);
                            animation.RemoveClip(clip);
                            clipTokens[i + 1] = clipKey;
                        }
                    }
                }
                if (IsClipTokensEmpty(clipTokens) == false)
                {
                    AssetBridgeHelper.AddEntry(go, this.Name, clipTokens);
                }
            }
            return(result);
        }
Example #6
0
        public override HashSet <string> Process(string entryPath, GameObject go, StrategyNode node)
        {
            HashSet <string> result = new HashSet <string>();
            Image            image  = go.GetComponent <Image>();

            if (image != null && image.material != null)
            {
                string materialPath = MaterialAssetProcessor.GetMaterialPath(image.material);
                if (node.pattern.IsMatch(materialPath))
                {
                    result.Add(materialPath);
                    image.materialKey = AssetPathHelper.GetObjectKey(entryPath, materialPath, image.material, node);
                    image.material    = null;
                    image.spriteKey   = AssetPathHelper.GetObjectKey(entryPath, materialPath, image.sprite, node);
                    image.sprite      = null;
                }
            }
            return(result);
        }
Example #7
0
        public HashSet <string> Process(string entryPath, Material material, StrategyNode node)
        {
            HashSet <string> result = new HashSet <string>();

            if (material == null)
            {
                Debug.LogError("资源打包出错, 缺少Material:" + entryPath);
            }
            string materialPath = MaterialAssetProcessor.GetMaterialPath(material);
            string shaderPath   = MaterialAssetProcessor.GetShaderPath(material.shader);

            if (node.pattern.IsMatch(shaderPath))
            {
                MaterialJsonData jsonData = MaterialJsonData.GetMaterialJsonData(materialPath);
                jsonData.shaderFileName = GetShaderFileName(material.shader);
                jsonData.shaderKey      = AssetPathHelper.GetObjectKey(entryPath, shaderPath, material.shader, node);
                jsonData.FillNoTexturePropertyData(material, node);
                result.Add(shaderPath);
            }
            return(result);
        }
        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);
            }
        }
 private static Dictionary <BuildTarget, string> GetBuildTargetIndentifierDict()
 {
     return(AssetPathHelper.GetBuildTargetIdentifierDict());
 }