From 7c93c2458fa72358d3b1ee43a8575cd42cc2d938 Mon Sep 17 00:00:00 2001 From: yyl <yyl> Date: 星期二, 01 七月 2025 17:37:51 +0800 Subject: [PATCH] 130 子 【战斗】战斗系统 / 【战斗】战斗系统-客户端 UI界面方便开关编辑器 /界面基础代码自动生成 /主线战斗编辑器 --- Assets/Editor/Tool/WindowTool.cs | 70 ++++++++++++++++++++++++++-------- 1 files changed, 53 insertions(+), 17 deletions(-) diff --git a/Assets/Editor/Tool/WindowTool.cs b/Assets/Editor/Tool/WindowTool.cs index 9caa2f6..d274c69 100644 --- a/Assets/Editor/Tool/WindowTool.cs +++ b/Assets/Editor/Tool/WindowTool.cs @@ -1,35 +1,71 @@ using UnityEngine; using UnityEditor; +using System.Collections.Generic; public class WindowTool : EditorWindow { - [MenuItem("Tools/绐楀彛绠$悊")] + private string windowName = ""; + private int selectedUIIndex = -1; + private List<string> uiNameList = new List<string>(); + + [MenuItem("Tools/WindowTool")] public static void ShowWindow() { - EditorWindow.GetWindow<WindowTool>("绐楀彛绠$悊").Show(); + GetWindow<WindowTool>("WindowTool"); } - - [SerializeField] - private string windowName; private void OnGUI() { + EditorGUILayout.LabelField("绐楀彛鍚嶇О", EditorStyles.boldLabel); + + // 鐩戝惉TextField鍙樺寲 + string newWindowName = EditorGUILayout.TextField("windowName", windowName); + if (newWindowName != windowName) + { + windowName = newWindowName; + selectedUIIndex = -1; // 鎵嬪姩杈撳叆鏃跺彇娑堥�変腑 + } + + // 鑾峰彇UIManager涓殑鐣岄潰鍒楄〃 + if (UIManager.Instance != null && UIManager.Instance.uiDict != null) + { + uiNameList.Clear(); + foreach (var kv in UIManager.Instance.uiDict) + { + uiNameList.Add(kv.Key); + } + + EditorGUILayout.Space(); + EditorGUILayout.LabelField("UI鐣岄潰鍒楄〃", EditorStyles.boldLabel); + + int clickedIndex = GUILayout.SelectionGrid(selectedUIIndex, uiNameList.ToArray(), 1); + + // 鍙鐐瑰嚮灏辫鐩杦indowName + if (clickedIndex >= 0 && clickedIndex < uiNameList.Count) + { + selectedUIIndex = clickedIndex; + windowName = uiNameList[selectedUIIndex]; + } + } + else + { + EditorGUILayout.HelpBox("UIManager.Instance 鎴� uiDict 鏈垵濮嬪寲", MessageType.Warning); + } + EditorGUILayout.Space(); + + // 淇濈暀鍘熸湁鐨勬墦寮�鍜屽叧闂寜閽� EditorGUILayout.BeginHorizontal(); - GUILayout.Label("绐楀彛鍚嶇О"); - EditorGUILayout.EndHorizontal(); - windowName = GUILayout.TextField(windowName, GUILayout.MinWidth(300)); if (GUILayout.Button("鎵撳紑")) { - OpenWindow(); + // 鎵撳紑绐楀彛閫昏緫 + UIManager.Instance.OpenWindow(windowName); } + if (GUILayout.Button("鍏抽棴")) + { + // 鍏抽棴绐楀彛閫昏緫 + UIManager.Instance.CloseWindow(windowName); + } + EditorGUILayout.EndHorizontal(); } - - private void OpenWindow() - { - if (string.IsNullOrEmpty(windowName) || !Application.isPlaying) - return; - UIManager.Instance.OpenWindow(windowName); - } - } \ No newline at end of file -- Gitblit v1.8.0