本文转自Unity Connect博主郡墙
Editor GUI 编辑器入门,常见对GUI界面编写及快速实现对介绍,附示例代码,hand by hand ,just do it.
基础GUI
文本类
示例代码
private void BaseAPI()
{
GUILayout.Label(mLableStr);
EditorGUILayout.SelectableLabel(mLabelField);
EditorGUILayout.LabelField("LabelField", mLabelField);
mTextField = EditorGUILayout.TextField("TextField", mTextField);
mIntField = EditorGUILayout.IntField("IntField", mIntField);
mFloatField = EditorGUILayout.FloatField("FloatField", mFloatField);
mTextArea = EditorGUILayout.TextArea(mTextArea, GUILayout.Height(40));
GUIStyle tempFontStyle = new GUIStyle();
tempFontStyle.normal.background = null;
tempFontStyle.normal.textColor = Color.yellow;
tempFontStyle.fontStyle = FontStyle.BoldAndItalic;
tempFontStyle.fontSize = 18;
GUILayout.Label(mCustomStr, tempFontStyle);
}
效果预览
密码输入样式
示例代码
private void PasswordField()
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Label("PasswordField_1");
mPasswordField_1 = GUILayout.PasswordField(mPasswordField_1, '*');
}
mPasswordField_2 = EditorGUILayout.PasswordFi