public static Rect GetControlRect (params GUILayoutOption[] options);
public static Rect GetControlRect (bool hasLabel, params GUILayoutOption[] options);
public static Rect GetControlRect (bool hasLabel, float height, params GUILayoutOption[] options);
public static Rect GetControlRect (bool hasLabel, float height, GUIStyle style, params GUILayoutOption[] options);

参数

hasLabel可选布尔值,用于指定控件是否有标签。默认值为 true。
height控件的高度(以像素为单位)。默认值为 EditorGUIUtility.singleLineHeight
style(可选)用于控件的 GUIStyle
options一个可选的布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 style 定义的设置。 另请参阅:GUILayout.WidthGUILayout.HeightGUILayout.MinWidthGUILayout.MaxWidthGUILayout.MinHeightGUILayout.MaxHeightGUILayout.ExpandWidthGUILayout.ExpandHeight

描述

获取编辑器控件的矩形。

在创建新的编辑器控件时,用于实现实际控件的声音设计并不依赖于 GUILayout,而是让控件将 Rect 作为参数,类似于 EditorGUI 类中的控件。这样可确保该控件还可以用于 PropertyDrawer 等类中,而此类中不允许使用 GUILayout。

实现控件的非布局版本后,也可以轻松创建布局版本,只需调用非布局版本即可。要获取适合控件的矩形,可以使用 GetControlRect 函数。