EditorWindow
编辑器的功能扩展,自定义一个编辑器窗口
实现步骤,新建一个C#类,继承与EditorWindow,在OnGUI方法中绘制UI,再设置一个触发窗口的方法
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class MyWindow : EditorWindow {
string myString = "Hello world";
bool groupEnabled;
bool myBool = true;
float myFloat = 1.23f;
[MenuItem("Window/My Window")]
public static void showWindow() {
EditorWindow.GetWindow (typeof(MyWindow));
}
void OnGUI() {
GUILayout.Label ("Base Settings", EditorStyles.boldLabel);
myString = EditorGUILayout.TextField ("Text Field", myString);
groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Setting", groupEnabled);
myBool = EditorGUILayout.Toggle ("Toggle", myBool);
myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
EditorGUILayout.EndToggleGroup ();
}
}
编译,然后回到Unity编辑器,这样就可以看到自己定义的窗口了