Editor-Window

it2025-09-27  6

简介


using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; using System; public class TestWindow : EditorWindow { [MenuItem("Window/TestWindow")] private static void Open() { TestWindow win = GetWindow<TestWindow>("lalala"); win.Show(); } private void OnGUI() { //标题 TopGUI(); //左侧区域 LeftGUI(); //右侧区域 RightGUI(); } private int _offsetw = 5; private int _offseth = 5; private int _btnw = 100; private int _btnh = 30; private void TopGUI() { //button for (int i = 0; i < 4; i++) { ButtonGUI(i, i.ToString()); } //toggle if (GUI.Toggle(new Rect((int)position.width-105,5,100,35),false,"toggle")) { } } private void ButtonGUI(int index, string name) { if (GUI.Button(new Rect(index * _btnw + _offsetw, _offseth, _btnw, _btnh), name)) { switch (name) { case "1": Debug.LogError("1"); break; default:Debug.LogError("0");break; } } } private void LeftGUI() { } private void RightGUI() { } }

参考

https://blog.csdn.net/qq992817263/article/details/79654398

最新回复(0)