diff --git a/06_工具脚本/UI工具/ExternalCommandListener.cs b/06_工具脚本/UI工具/ExternalCommandListener.cs index 270d2bf..7610806 100644 --- a/06_工具脚本/UI工具/ExternalCommandListener.cs +++ b/06_工具脚本/UI工具/ExternalCommandListener.cs @@ -148,18 +148,6 @@ public static class ExternalCommandListener } } - [MenuItem("Tools/External/Test ReadJson")] - public static void TestExecuteReadJson() - { - ExecuteReadJson(new string[0]); - } - - [MenuItem("Tools/External/Test GenerateUIPrefab")] - public static void TestExecuteGenerateUIPrefab() - { - ExecuteGenerateUIPrefab(new[] { "Assets/Editor/UI/BagWindow.json" }); - } - private static void ExecuteExportPrefabToJson(string[] args) { try @@ -185,10 +173,4 @@ public static class ExternalCommandListener Debug.LogError("ExportPrefabToJson failed: " + ex.Message); } } - - [MenuItem("Tools/External/Test ExportPrefabToJson")] - public static void TestExecuteExportPrefabToJson() - { - ExecuteExportPrefabToJson(new[] { "Assets/Game/GameHFResource/CN/UIWindows/BagWindow/BagWindow.prefab" }); - } } \ No newline at end of file diff --git a/06_工具脚本/UI工具/UIPrefabGenerator.cs b/06_工具脚本/UI工具/UIPrefabGenerator.cs index 346489c..61ff34e 100644 --- a/06_工具脚本/UI工具/UIPrefabGenerator.cs +++ b/06_工具脚本/UI工具/UIPrefabGenerator.cs @@ -8,46 +8,6 @@ using TMPro; public static class UIPrefabGenerator { - [MenuItem("Tools/UI/Generate BagWindow Prefab")] - public static void GenerateBagWindowPrefab() - { - string jsonPath = "Assets/Editor/UI/BagWindow.json"; - string prefabPath = "Assets/Game/GameHFResource/CN/UIWindows/BagWindow/BagWindow.prefab"; - - if (!File.Exists(jsonPath)) - { - Debug.LogError("JSON file not found: " + jsonPath); - return; - } - - string jsonContent = File.ReadAllText(jsonPath); - UILayoutData layoutData = JsonUtility.FromJson(jsonContent); - - GameObject root = new GameObject(layoutData.name); - root.layer = 5; - - Canvas canvas = root.AddComponent(); - canvas.renderMode = RenderMode.ScreenSpaceOverlay; - canvas.pixelPerfect = layoutData.canvas.pixelPerfect; - - root.AddComponent(); - root.AddComponent(); - - RectTransform rootRect = root.GetComponent(); - SetRectTransform(rootRect, layoutData.rectTransform); - - foreach (var childData in layoutData.children) - { - CreateUIElement(childData, root.transform); - } - - CreatePrefab(root, prefabPath); - GameObject.DestroyImmediate(root); - - AssetDatabase.Refresh(); - Debug.Log("UI Prefab generated successfully: " + prefabPath); - } - public static void GeneratePrefabFromJson(string jsonPath, string prefabPath = null) { if (!File.Exists(jsonPath)) diff --git a/06_工具脚本/UI工具/UIPrefabToJson.cs b/06_工具脚本/UI工具/UIPrefabToJson.cs index 283249e..18f6496 100644 --- a/06_工具脚本/UI工具/UIPrefabToJson.cs +++ b/06_工具脚本/UI工具/UIPrefabToJson.cs @@ -9,19 +9,6 @@ using TMPro; public static class UIPrefabToJson { - [MenuItem("Tools/UI/Export Prefab to JSON")] - public static void ExportPrefabToJsonMenu() - { - string prefabPath = EditorUtility.OpenFilePanel("选择预制体", "Assets", "prefab"); - if (!string.IsNullOrEmpty(prefabPath)) - { - string projectPath = Application.dataPath.Replace("/Assets", ""); - string relativePath = prefabPath.Replace(projectPath + "/", ""); - string jsonPath = relativePath.Replace(".prefab", ".json"); - ExportPrefabToJson(relativePath, jsonPath); - } - } - public static void ExportPrefabToJson(string prefabPath, string jsonPath = null) { if (!AssetDatabase.LoadAssetAtPath(prefabPath))