2025-12-01 16:46:28 +08:00
|
|
|
using System.Linq;
|
2025-12-09 20:31:44 +08:00
|
|
|
using AlicizaX.UXTool;
|
2025-12-01 16:46:28 +08:00
|
|
|
using AlicizaX.AnimationFlow.Runtime;
|
|
|
|
|
using AlicizaX.Localization.Editor;
|
|
|
|
|
using AlicizaX.Localization.Runtime;
|
|
|
|
|
using AlicizaX.UI.Editor;
|
|
|
|
|
using Paps.UnityToolbarExtenderUIToolkit;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UIElements;
|
|
|
|
|
|
2025-12-09 20:31:44 +08:00
|
|
|
namespace AlicizaX.UXTool
|
2025-12-01 16:46:28 +08:00
|
|
|
{
|
|
|
|
|
[MainToolbarElement("ToolBarUXAnimation", alignment: ToolbarAlign.Right, order: 1)]
|
|
|
|
|
public class ToolBarUXAnimation : IMGUIContainer
|
|
|
|
|
{
|
|
|
|
|
private GUIContent btnAnimation;
|
|
|
|
|
|
|
|
|
|
public void InitializeElement()
|
|
|
|
|
{
|
|
|
|
|
btnAnimation = EditorGUIUtility.TrTextContentWithIcon("动画编辑", "", "AnimationClip Icon");
|
|
|
|
|
UXDesinUtil.OnEnterDesignMode += OnEntryDesignMode;
|
|
|
|
|
UXDesinUtil.OnExitDesignMode += OnExitDesignMode;
|
|
|
|
|
if (UXDesinUtil.InDesign)
|
|
|
|
|
OnEntryDesignMode();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OnExitDesignMode();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnExitDesignMode()
|
|
|
|
|
{
|
|
|
|
|
onGUIHandler = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEntryDesignMode()
|
|
|
|
|
{
|
|
|
|
|
onGUIHandler = MyGUIMethod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MyGUIMethod()
|
|
|
|
|
{
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
if (GUILayout.Button(btnAnimation, EditorStyles.toolbarButton, GUILayout.MaxWidth(120)))
|
|
|
|
|
{
|
|
|
|
|
var gameObject = PrefabStageUtils.StageRoot.gameObject;
|
2025-12-09 20:31:44 +08:00
|
|
|
if (!gameObject.TryGetComponent(typeof(AnimationFlow.Runtime.AnimationFlow), out Component flow))
|
2025-12-01 16:46:28 +08:00
|
|
|
{
|
2025-12-09 20:31:44 +08:00
|
|
|
gameObject.AddComponent(typeof(AnimationFlow.Runtime.AnimationFlow));
|
2025-12-01 16:46:28 +08:00
|
|
|
}
|
|
|
|
|
Selection.activeGameObject = PrefabStageUtils.StageRoot.gameObject;
|
|
|
|
|
UnityEditor.EditorApplication.ExecuteMenuItem("Window/AnimationGraph");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GUILayout.Space(5);
|
|
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MainToolbarElement("ToolBarExportUIScriptCode", alignment: ToolbarAlign.Right, order: 1)]
|
|
|
|
|
public class ToolBarExportUIScriptCode : IMGUIContainer
|
|
|
|
|
{
|
|
|
|
|
private GUIContent exportBtn;
|
|
|
|
|
|
|
|
|
|
public void InitializeElement()
|
|
|
|
|
{
|
|
|
|
|
exportBtn = EditorGUIUtility.TrTextContentWithIcon("导出代码", "", "cs Script Icon");
|
|
|
|
|
UXDesinUtil.OnEnterDesignMode += OnEntryDesignMode;
|
|
|
|
|
UXDesinUtil.OnExitDesignMode += OnExitDesignMode;
|
|
|
|
|
if (UXDesinUtil.InDesign)
|
|
|
|
|
OnEntryDesignMode();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OnExitDesignMode();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnExitDesignMode()
|
|
|
|
|
{
|
|
|
|
|
onGUIHandler = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnEntryDesignMode()
|
|
|
|
|
{
|
|
|
|
|
onGUIHandler = MyGUIMethod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MyGUIMethod()
|
|
|
|
|
{
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
if (GUILayout.Button(exportBtn, EditorStyles.toolbarButton, GUILayout.MaxWidth(120)))
|
|
|
|
|
{
|
|
|
|
|
Selection.activeGameObject = PrefabStageUtils.StageRoot.gameObject;
|
|
|
|
|
UIGenerateQuick.UIGenerateBind();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GUILayout.Space(5);
|
|
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[MainToolbarElement(id: "ToolBarExitDesign", alignment: ToolbarAlign.Right, order: 3)]
|
|
|
|
|
public class ToolBarExitDesign : IMGUIContainer
|
|
|
|
|
{
|
|
|
|
|
private GUIContent entryBtnContent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void InitializeElement()
|
|
|
|
|
{
|
|
|
|
|
entryBtnContent = EditorGUIUtility.TrTextContentWithIcon("Exit Design", "", EditorGUIUtility.IconContent("d_BuildSettings.Standalone").image);
|
|
|
|
|
onGUIHandler = MyGUIMethod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MyGUIMethod()
|
|
|
|
|
{
|
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
|
|
|
|
|
if (UXDesinUtil.InDesign)
|
|
|
|
|
{
|
|
|
|
|
entryBtnContent.text = "退出UI编辑器";
|
|
|
|
|
if (GUILayout.Button(entryBtnContent, EditorStyles.toolbarButton, GUILayout.MaxWidth(125)))
|
|
|
|
|
{
|
|
|
|
|
UXDesinUtil.ExitUIDesinger();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entryBtnContent.text = "进入UI编辑器";
|
|
|
|
|
if (GUILayout.Button(entryBtnContent, EditorStyles.toolbarButton, GUILayout.MaxWidth(125)))
|
|
|
|
|
{
|
|
|
|
|
UXDesinUtil.OpenUIDesinger();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
}
|
|
|
|
|
}
|