区分:EditorGUI为固定布局,EditorGUILayout为自动布局
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class TestEditor : EditorWindow
{
[MenuItem("MyMenu/TestItem")]
static void Test()
{
TestEditor testEditor = (TestEditor)EditorWindow.GetWindow(typeof(TestEditor));
testEditor.Show();
}
float f1;
float f2;
string s1;
string s2;
void OnGUI()
{
if (GUILayout.Button("关闭"))
{
this.Close();
}
EditorGUI.BeginDisabledGroup(true);
f1 = EditorGUILayout.FloatField("单精度1", f1);
s1 = EditorGUILayout.TextField("字符串1", s1);
EditorGUI.EndDisabledGroup();
f2 = EditorGUILayout.FloatField("单精度2", f2);
s2 = EditorGUILayout.TextField("字符串2", s2);
}
}