删除所有工具脚本中的测试菜单代码(Tools菜单下的测试项)
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user