public static void LabelField (string label, params GUILayoutOption[] options);
public static void LabelField (string label, GUIStyle style, params GUILayoutOption[] options);
public static void LabelField (GUIContent label, params GUILayoutOption[] options);
public static void LabelField (GUIContent label, GUIStyle style, params GUILayoutOption[] options);
public static void LabelField (string label, string label2, params GUILayoutOption[] options);
public static void LabelField (string label, string label2, GUIStyle style, params GUILayoutOption[] options);
public static void LabelField (GUIContent label, GUIContent label2, params GUILayoutOption[] options);
public static void LabelField (GUIContent label, GUIContent label2, GUIStyle style, params GUILayoutOption[] options);

Parameters

label标签字段前的标签。
label2显示在右侧的标签。
options一个可选的布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 style 定义的设置。
另请参阅:GUILayout.WidthGUILayout.HeightGUILayout.MinWidthGUILayout.MaxWidthGUILayout.MinHeightGUILayout.MaxHeightGUILayout.ExpandWidthGUILayout.ExpandHeight

Description

生成一个标签字段。(用于显示只读信息。)


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(); } }