添加窗口任务栏功能,添加窗口的管理功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using XericUI.Form;
|
||||
|
||||
namespace XericUIEditor.Form
|
||||
{
|
||||
@@ -24,8 +25,6 @@ namespace XericUIEditor.Form
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
#region 基本设置
|
||||
|
||||
private void DrawBasicSection()
|
||||
{
|
||||
EditorGUILayout.LabelField("窗口基本设置", EditorStyles.boldLabel);
|
||||
@@ -33,10 +32,6 @@ namespace XericUIEditor.Form
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 边缘行为
|
||||
|
||||
private void DrawEdgeSection()
|
||||
{
|
||||
EditorGUILayout.LabelField("边缘吸附", EditorStyles.boldLabel);
|
||||
@@ -58,10 +53,6 @@ namespace XericUIEditor.Form
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 调试与测试
|
||||
|
||||
private void DrawDebugSection()
|
||||
{
|
||||
EditorGUILayout.LabelField("调试", EditorStyles.boldLabel);
|
||||
@@ -72,74 +63,49 @@ namespace XericUIEditor.Form
|
||||
|
||||
// 当前状态
|
||||
EditorGUILayout.LabelField("当前状态", EditorStyles.boldLabel);
|
||||
|
||||
var state = _controller.CurrentState;
|
||||
Color stateColor;
|
||||
string stateText;
|
||||
|
||||
switch (state)
|
||||
Color stateColor = state switch
|
||||
{
|
||||
case XericUI.Form.WindowState.Normal:
|
||||
stateColor = Color.white;
|
||||
stateText = "● 窗口化 (Normal)";
|
||||
break;
|
||||
case XericUI.Form.WindowState.Maximized:
|
||||
stateColor = Color.green;
|
||||
stateText = "■ 全屏 (Maximized)";
|
||||
break;
|
||||
case XericUI.Form.WindowState.Minimized:
|
||||
stateColor = Color.gray;
|
||||
stateText = "○ 最小化 (Minimized)";
|
||||
break;
|
||||
case XericUI.Form.WindowState.EdgeHidden:
|
||||
stateColor = new Color(1f, 0.6f, 0f);
|
||||
stateText = "◄ 边缘隐藏 (Edge Hidden)";
|
||||
break;
|
||||
default:
|
||||
stateColor = Color.white;
|
||||
stateText = state.ToString();
|
||||
break;
|
||||
}
|
||||
XericUI.Form.WindowState.Normal => Color.white,
|
||||
XericUI.Form.WindowState.Maximized => Color.green,
|
||||
XericUI.Form.WindowState.Minimized => Color.gray,
|
||||
XericUI.Form.WindowState.EdgeHidden => new Color(1f, 0.6f, 0f),
|
||||
_ => Color.white
|
||||
};
|
||||
var entries = _controller.Manager?.GetAllEntries();
|
||||
WindowEntry entry = _controller.Entry;
|
||||
string extra = entry != null ? $" | ID={entry.Id}" : "";
|
||||
|
||||
GUI.color = stateColor;
|
||||
EditorGUILayout.LabelField(stateText, EditorStyles.miniBoldLabel);
|
||||
EditorGUILayout.LabelField($"{state}{extra}", EditorStyles.miniBoldLabel);
|
||||
GUI.color = Color.white;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
// 手动测试按钮
|
||||
// 手动测试
|
||||
EditorGUILayout.LabelField("手动测试", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("全屏/还原"))
|
||||
{
|
||||
_controller.ToggleMaximize();
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
if (GUILayout.Button("模拟进入"))
|
||||
if (GUILayout.Button("置顶 (Focus)"))
|
||||
{
|
||||
_controller.SimulateEnter();
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
if (GUILayout.Button("模拟退出"))
|
||||
{
|
||||
_controller.SimulateExit();
|
||||
_controller.MoveToFront();
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
// 调试提示
|
||||
if (!Application.isPlaying && _controller.DebugMode)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
"调试模式已启用 — 在 SceneView 中移动鼠标即可预览。\n" +
|
||||
"蓝色边框 = 窗口范围 | 绿色 = 鼠标悬停中 | 橙色 = 吸附阈值范围",
|
||||
"调试模式已启用 — SceneView 中移动鼠标实时预览。\n" +
|
||||
"蓝色边框=窗口范围 | 绿色=鼠标悬停中",
|
||||
MessageType.Info);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericUIEditor.Form
|
||||
{
|
||||
[CustomEditor(typeof(XericUI.Form.UITaskBar))]
|
||||
public class UITaskBarEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("任务栏绑定", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Manager"), new GUIContent("窗口管理器 (Manager)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ItemPrefab"), new GUIContent("图标预制体 (Item Prefab)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ItemsContainer"), new GUIContent("图标容器 (Container)"));
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(XericUI.Form.UITaskBarItem))]
|
||||
public class UITaskBarItemEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("任务栏图标项控件", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Icon"), new GUIContent("图标 (Icon)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_TitleText"), new GUIContent("标题文本 (Title)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ProgressBar"), new GUIContent("进度条 (Progress Bar)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Highlight"), new GUIContent("聚焦高亮 (Highlight)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Button"), new GUIContent("按钮 (Button)"));
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dfbe31f222f10a4883ad6016cdad32b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,26 +6,20 @@ namespace XericUIEditor.Form
|
||||
[CustomEditor(typeof(XericUI.Form.UITitleBar))]
|
||||
public class UITitleBarEditor : Editor
|
||||
{
|
||||
private XericUI.Form.UITitleBar _titleBar;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_titleBar = (XericUI.Form.UITitleBar)target;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("标题栏控件引用", EditorStyles.boldLabel);
|
||||
EditorGUILayout.HelpBox(
|
||||
"将标题栏下的子控件拖入下方槽位即可。\n" +
|
||||
"UITitleBar 会在 Start 时自动向上查找父级的 UIFormController 并绑定事件。",
|
||||
"将标题栏下的子控件拖入下方槽位。\n" +
|
||||
"UITitleBar 在 Start 时向上查找父级 UIFormController 并绑定事件。",
|
||||
MessageType.Info);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_IconImage"), new GUIContent("窗口图标 (Icon Image)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_TitleText"), new GUIContent("标题文本 (Title Text)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_CloseButton"), new GUIContent("关闭按钮 (Close)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_MaximizeButton"), new GUIContent("最大化按钮 (Maximize)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_MaximizeToggle"), new GUIContent("最大化 Toggle (Maximize)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_MinimizeButton"), new GUIContent("最小化按钮 (Minimize)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_AutoSnapToggle"), new GUIContent("吸附开关 (Auto Snap)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_AutoHideToggle"), new GUIContent("隐藏开关 (Auto Hide)"));
|
||||
|
||||
Reference in New Issue
Block a user