删除所有工具脚本中的测试菜单代码(Tools菜单下的测试项)

This commit is contained in:
Shiliang
2026-05-27 16:51:51 +08:00
parent 3404f89f93
commit bc87ac4d9c
3 changed files with 0 additions and 71 deletions

View File

@@ -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" });
}
}

View File

@@ -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<UILayoutData>(jsonContent);
GameObject root = new GameObject(layoutData.name);
root.layer = 5;
Canvas canvas = root.AddComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
canvas.pixelPerfect = layoutData.canvas.pixelPerfect;
root.AddComponent<CanvasScaler>();
root.AddComponent<GraphicRaycaster>();
RectTransform rootRect = root.GetComponent<RectTransform>();
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))

View File

@@ -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<GameObject>(prefabPath))