public static Rect BeginHorizontal (params GUILayoutOption[] options);
public static Rect BeginHorizontal (GUIStyle style, params GUILayoutOption[] options);

Parameters

style可选 GUIStyle
options一个可选的布局选项列表,用于指定额外的 布局属性。此处传递的任何值都将覆盖 style 定义的设置。
另请参阅:GUILayout.WidthGUILayout.HeightGUILayout.MinWidthGUILayout.MaxWidthGUILayout.MinHeightGUILayout.MaxHeightGUILayout.ExpandWidthGUILayout.ExpandHeight

Description

开始一个水平组并找回其矩形。

此方法是对 GUILayout.BeginHorizontal 的扩展。可用于创建复合控件。


Horizontal Compound group.

// Create a Horizontal Compound Button

using UnityEngine; using UnityEditor;

public class BeginEndHorizontalExample : EditorWindow { [MenuItem("Examples/Begin-End Horizontal usage")] static void Init() { BeginEndHorizontalExample window = (BeginEndHorizontalExample)GetWindow(typeof(BeginEndHorizontalExample)); window.Show(); }

void OnGUI() { Rect r = EditorGUILayout.BeginHorizontal("Button"); if (GUI.Button(r, GUIContent.none)) Debug.Log("Go here"); GUILayout.Label("I'm inside the button"); GUILayout.Label("So am I"); EditorGUILayout.EndHorizontal(); } }