文本
void OnGUI()
{
GUILayout.Label("文本", EditorStyles.boldLabel);
}
文本框
string myString = "文本框123";
void OnGUI()
{
myString = EditorGUILayout.TextField("文本框:", myString);
}
自定义字体
void OnGUI()
{
GUIStyle fontStyle = new GUIStyle();
fontStyle.normal.background = null; //设置背景填充
fontStyle.normal.textColor = Color.red; //设置字体颜色
fontStyle.fontStyle = FontStyle.BoldAndItalic; // 字体加粗倾斜
fontStyle.fontSize = 18; //字体大小
GUILayout.Label("自定义字体", fontStyle);
}
区域输入框
void OnGUI()
{
GUILayout.Label ("留言簿:");
areaText = GUILayout.TextArea(areaText, GUILayout.Height(40));
}
密码框
string password;
void OnGUI()
{
password = EditorGUILayout.PasswordField ("密码", password);
}
枚举弹出菜单
SystemLanguage language;
void OnGUI()
{
language = (SystemLanguage)EditorGUILayout.EnumPopup("语言:", language);//枚举弹出菜单
}
开关
bool test;
void OnGUI()
{
test = EditorGUILayout.Toggle("开关:", test);
}
页签
int toolbar;
string[] texts = { "A", "B", "C" };
void OnGUI()
{
toolbar = GUILayout.Toolbar(toolbar,texts);
switch (toolbar)
{
case 0:
GUILayout.Label("a");
GUILayout.Label("aa");
GUILayout.Label("aaa");
GUILayout.Label("aaaa");
GUILayout.Label("aaaaa");
GUILayout.Label("aaaaaa");
break;
case 1:
GUILayout.Label("b");
GUILayout.Label("bb");
GUILayout.Label("bbb");
GUILayout.Label("bbbb");
GUILayout.Label("bbbbb");
GUILayout.Label("bbbbbb");
break;
case 2:
GUILayout.Label("c");
GUILayout.Label("cc");
GUILayout.Label("ccc");
GUILayout.Label("cccc");
GUILayout.Label("ccccc");
GUILayout.Label("cccccc");
break;
}
}
滑动条
float slider = 0;
void OnGUI()
{
slider = EditorGUILayout.Slider(slider, 1, 10);
}
设置Tag
private string tagStr;
void OnGUI()
{
tagStr = EditorGUILayout.TagField("Tag:", tagStr,GUILayout.Width(250));
}
通知提示
private string notification = "ShowNotification";
void OnGUI()
{
notification = EditorGUILayout.TextField (notification);
this.ShowNotification (new GUIContent (notification));
}