修改
This commit is contained in:
parent
8746a69c62
commit
7157a9fa25
@ -2,20 +2,22 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AlicizaX.UI.Editor
|
||||
{
|
||||
public static class UIGenerateEditorTool
|
||||
{
|
||||
[MenuItem("GameObject/UI工具/热更工程UI代码", priority = -1)]
|
||||
public static void GenerateHotfixUIScript()
|
||||
{
|
||||
UIGenerateWindow.ShowWindow(Selection.gameObjects.FirstOrDefault(),UIGenerateConfiguration.Instance.UIScriptGenerateConfig.HotFixProjectUIScriptGenerateData);
|
||||
namespace AlicizaX.UI.Editor {
|
||||
public static class UIGenerateEditorTool {
|
||||
[MenuItem("GameObject/UI生成绑定/热更工程UI代码", priority = 10)]
|
||||
public static void GenerateHotfixUIScript() {
|
||||
UIScriptGeneratorHelper.GenerateAndAttachScript(
|
||||
Selection.gameObjects.FirstOrDefault(),
|
||||
UIGenerateConfiguration.Instance.UIScriptGenerateConfig.HotFixProjectUIScriptGenerateData
|
||||
);
|
||||
}
|
||||
|
||||
[MenuItem("GameObject/UI工具/主工程UI代码", priority = -1)]
|
||||
public static void GenerateMainUIScript()
|
||||
{
|
||||
UIGenerateWindow.ShowWindow(Selection.gameObjects.FirstOrDefault(),UIGenerateConfiguration.Instance.UIScriptGenerateConfig.MainProjectUIScriptGenerateData);
|
||||
[MenuItem("GameObject/UI生成绑定/主工程UI代码", priority = 21)]
|
||||
public static void GenerateMainUIScript() {
|
||||
UIScriptGeneratorHelper.GenerateAndAttachScript(
|
||||
Selection.gameObjects.FirstOrDefault(),
|
||||
UIGenerateConfiguration.Instance.UIScriptGenerateConfig.MainProjectUIScriptGenerateData
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bfa0d164c11486cb3a133829d53dccf
|
||||
timeCreated: 1739339632
|
@ -44,7 +44,7 @@ namespace AlicizaX.UI.Editor
|
||||
}
|
||||
|
||||
|
||||
public static class UIScriptGeneratorHelper
|
||||
internal static class UIScriptGeneratorHelper
|
||||
{
|
||||
private static UIGenerateConfiguration _uiGenerateConfiguration;
|
||||
|
||||
@ -305,6 +305,7 @@ namespace AlicizaX.UI.Editor
|
||||
|
||||
public static void GenerateAndAttachScript(GameObject targetObject, UIScriptGenerateData scriptGenerateData)
|
||||
{
|
||||
EditorPrefs.SetInt("InstanceId", targetObject.GetInstanceID());
|
||||
UIBindDatas.Clear();
|
||||
GenerateNameSpace = scriptGenerateData.NameSpace;
|
||||
ArrayComs.Clear();
|
||||
@ -377,12 +378,25 @@ namespace AlicizaX.UI.Editor
|
||||
UIBindDatas.Clear();
|
||||
ArrayComs.Clear();
|
||||
var className = EditorPrefs.GetString("Generate");
|
||||
var targetObject = UIGenerateWindow.GetTargetObject();
|
||||
// var targetObject = UIGenerateWindow.GetTargetObject();
|
||||
int instanceId = EditorPrefs.GetInt("InstanceId", -1);
|
||||
if (instanceId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var targetObject = (GameObject)EditorUtility.InstanceIDToObject(instanceId);
|
||||
|
||||
if (!targetObject)
|
||||
{
|
||||
Debug.Log("UI脚本生成附加物体丢失!");
|
||||
}
|
||||
|
||||
EditorPrefs.DeleteKey("Generate");
|
||||
GetBindData(targetObject.transform);
|
||||
|
||||
AttachScriptToGameObject(targetObject, className);
|
||||
Debug.Log($"Generate {className} Successfully attached to game object");
|
||||
UIGenerateWindow.CloseWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ using UnityEngine.Windows;
|
||||
|
||||
namespace AlicizaX.UI.Editor
|
||||
{
|
||||
public class UISettingEditorWindow : OdinEditorWindow
|
||||
internal class UISettingEditorWindow : OdinEditorWindow
|
||||
{
|
||||
[MenuItem("Tools/AlicizaX/UI Setting Window")]
|
||||
private static void OpenWindow()
|
||||
|
@ -46,7 +46,7 @@ namespace AlicizaX.UI.Runtime
|
||||
|
||||
[SerializeField]
|
||||
[HideLabel]
|
||||
internal UXButton[] hotButtons;
|
||||
private UXButton[] hotButtons;
|
||||
|
||||
internal void BindHotKeys()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user