| | |
| | | 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"; |
| | | |
| | |
| | | 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) |
| | |
| | | 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() |
| | |
| | | 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() |
| | |
| | | csharpFileContents = GetAllCSharpFileContents(); |
| | | generalContent = GetGeneralContent(); |
| | | prefabTexts = GetPrefabTexts(); |
| | | scriptableObjects = GetScriptableObjects(); |
| | | |
| | | try |
| | | { |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | foreach (var file in files) |
| | | { |
| | | count++; |
| | | EditorUtility.DisplayProgressBar("读取代码文件","正在读取代码文件",(float) count/files.Count); |
| | | EditorUtility.DisplayProgressBar("读取代码文件", "正在读取代码文件", (float)count / files.Count); |
| | | contents.Add(File.ReadAllText(file.FullName)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | var count = 0; |
| | | prefabTexts = new List<string>(); |
| | | var prefabTexts = new List<string>(); |
| | | foreach (var path in assetPaths) |
| | | { |
| | | count++; |
| | |
| | | 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) |
| | |
| | | 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; |