少年修仙传客户端基础资源
client_Wu Xijin
2019-04-19 f95c2811171633089350727be4c245d099de6157
3335  更新ui资源整理工具
1个文件已修改
69 ■■■■ 已修改文件
Assets/Editor/Tool/UIAssetCheck.cs 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/UIAssetCheck.cs
@@ -89,6 +89,7 @@
    static string uiroot1 = "Assets/ResourcesOut/UI/Window";
    static string uiroot2 = "Assets/ResourcesOut/UI/PriorityWindow";
    static string uiroot3 = "Assets/ResourcesOut/UI/Prefab";
    static string uiroot4 = "Assets/ResourcesOut/UI/Treasure/Misc";
    static string spriteroot = "Assets/ResourcesOut/UI/Sprite";
@@ -136,6 +137,7 @@
        guids.AddRange(AssetDatabase.FindAssets("t:prefab", new string[] { uiroot1 }));
        guids.AddRange(AssetDatabase.FindAssets("t:prefab", new string[] { uiroot2 }));
        guids.AddRange(AssetDatabase.FindAssets("t:prefab", new string[] { uiroot3 }));
        guids.AddRange(AssetDatabase.FindAssets("t:prefab", new string[] { uiroot4 }));
        var assetPaths = new List<string>();
        foreach (var item in guids)
@@ -143,11 +145,17 @@
            assetPaths.Add(AssetDatabase.GUIDToAssetPath(item));
        }
        var totalCount = assetPaths.Count;
        var count = 0;
        prefabTexts.Clear();
        foreach (var path in assetPaths)
        {
            count++;
            EditorUtility.DisplayProgressBar("读取预置体文本", "正在读取预置体文本", count / (float)totalCount);
            prefabTexts.Add(File.ReadAllText(Application.dataPath + path.Substring(6, path.Length - 6)));
        }
        EditorUtility.ClearProgressBar();
    }
    static void FindSprites()
@@ -401,6 +409,7 @@
    static List<string> csharpFileContents = new List<string>();
    static string generalContent = string.Empty;
    static List<AnalyzeTask> tasks = new List<AnalyzeTask>();
    static List<string> scriptableObjects = new List<string>();
    [MenuItem("程序/UI Assets/移除无用的IconKey")]
    public static void Remove()
@@ -436,6 +445,7 @@
        csharpFileContents = GetAllCSharpFileContents();
        generalContent = GetGeneralContent();
        prefabTexts = GetPrefabTexts();
        scriptableObjects = GetScriptableObjects();
        try
        {
@@ -467,15 +477,21 @@
                        continue;
                    }
                    if (ContainByCSharpFile(info.key, ref csharpFileContents))
                    {
                        // Debug.LogFormat("找到一个写在C#文件中的 icon key:{0}", info.key);
                        continue;
                    }
                    if (ContainByGeneralConfig(info.key, ref generalContent))
                    {
                        // Debug.LogFormat("找到一个写在功能配置表中的 icon key:{0}", info.key);
                        continue;
                    }
                    if (ContainBySriptableObjects(info.key, ref scriptableObjects))
                    {
                        // Debug.LogFormat("找到一个配置在ScriptObject文件中的 icon key:{0}", info.key);
                        continue;
                    }
                    if (ContainByCSharpFile(info.key, ref csharpFileContents))
                    {
                        // Debug.LogFormat("找到一个写在C#文件中的 icon key:{0}", info.key);
                        continue;
                    }
@@ -635,7 +651,7 @@
        foreach (var file in files)
        {
            count++;
            EditorUtility.DisplayProgressBar("读取代码文件","正在读取代码文件",(float) count/files.Count);
            EditorUtility.DisplayProgressBar("读取代码文件", "正在读取代码文件", (float)count / files.Count);
            contents.Add(File.ReadAllText(file.FullName));
        }
@@ -659,7 +675,7 @@
        }
        var count = 0;
        prefabTexts = new List<string>();
        var prefabTexts = new List<string>();
        foreach (var path in assetPaths)
        {
            count++;
@@ -674,6 +690,30 @@
    static string GetGeneralContent()
    {
        return File.ReadAllText(Application.dataPath + "/ResourcesOut/Refdata/Config/FuncConfig.txt");
    }
    static List<string> GetScriptableObjects()
    {
        var guids = new List<string>();
        guids.AddRange(AssetDatabase.FindAssets("t:ScriptableObject", new string[] { "Assets/ResourcesOut/BuiltIn/ScriptableObjects" }));
        var assetPaths = new List<string>();
        foreach (var item in guids)
        {
            assetPaths.Add(AssetDatabase.GUIDToAssetPath(item));
        }
        var count = 0;
        var scriptableObjects = new List<string>();
        foreach (var path in assetPaths)
        {
            count++;
            EditorUtility.DisplayProgressBar("读取ScriptableObject", "正在读取ScriptableObject", (float)count / assetPaths.Count);
            scriptableObjects.Add(File.ReadAllText(Application.dataPath + path.Substring(6, path.Length - 6)));
        }
        EditorUtility.ClearProgressBar();
        return scriptableObjects;
    }
    static bool ContainByTables(string key, ref List<Column> columns)
@@ -732,6 +772,19 @@
        return false;
    }
    static bool ContainBySriptableObjects(string key, ref List<string> scriptableObjects)
    {
        foreach (var text in scriptableObjects)
        {
            if (Regex.IsMatch(text, key))
            {
                return true;
            }
        }
        return false;
    }
    static void OnUpdate()
    {
        var done = true;