com.alicizax.unity.framework/Editor/UI/GenerateTool/UIGenerateEditorWindow.cs

43 lines
1.2 KiB
C#
Raw Normal View History

2025-09-05 19:46:30 +08:00
using UnityEditor;
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using AlicizaX.UI.Editor;
using AlicizaX.UI.Runtime;
using UnityEngine.UIElements;
public class UIGenerateWindow : EditorWindow
{
private GameObject targetObject;
public static GameObject GetTargetObject()
{
return GetWindow<UIGenerateWindow>().targetObject;
}
public static void ShowWindow(GameObject target, UIScriptGenerateData scriptGenerateData)
{
var window = GetWindow<UIGenerateWindow>(false, "UI Config Editor", false);
window.maxSize = Vector2.zero;
window.minSize = Vector2.zero;
window.rootVisualElement.style.display = DisplayStyle.None;
window.rootVisualElement.parent.style.display = DisplayStyle.None;
window.Initlize(target, scriptGenerateData);
}
public static void CloseWindow()
{
var window = GetWindow<UIGenerateWindow>(false, "UI Config Editor");
window.Close();
}
private void Initlize(GameObject target, UIScriptGenerateData scriptGenerateData)
{
targetObject = target;
UIScriptGeneratorHelper.GenerateAndAttachScript(targetObject, scriptGenerateData);
}
}