label | 标签字段前的标签。 |
label2 | 显示在右侧的标签。 |
options | 一个可选的布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 style 定义的设置。另请参阅:GUILayout.Width、GUILayout.Height、GUILayout.MinWidth、GUILayout.MaxWidth、GUILayout.MinHeight、 GUILayout.MaxHeight、GUILayout.ExpandWidth、GUILayout.ExpandHeight。 |
生成一个标签字段。(用于显示只读信息。)
Shows a label in the editor (Label) with the seconds since the editor started (Label2).
// Shows a label in the editor with the seconds since the editor started
using UnityEditor;
using UnityEngine;
public class LabelFieldExample : EditorWindow
{
[MenuItem("Examples/Editor GUILayout Label Usage")]
static void Init()
{
LabelFieldExample window = (LabelFieldExample)EditorWindow.GetWindow(typeof(LabelFieldExample), true, "My Empty Window");
window.Show();
}
void OnGUI()
{
EditorGUILayout.LabelField("Time since start: ",
EditorApplication.timeSinceStartup.ToString());
this.Repaint();
}
}