GUILayoutOptions

GUILayoutOptions is a handy utility that provides cached GUILayoutOpion arrays based on the wanted parameters.

namespace Sirenix.Utilities
{
public static class GUILayoutOptions
}

Requirements

Namespace: Sirenix.Utilities
Assembly: Sirenix.OdinInspector
Version: 2.0.0.0

Static Fields

Return Type Definition Description
GUILayoutOption[] EmptyGUIOptions An EmptyGUIOption[] array with a length of 0.

Static Methods

Return Type Definition Description
GUILayoutOptionsInstance ExpandHeight(bool) Option passed to a control to allow or disallow vertical expansion.
GUILayoutOptionsInstance ExpandWidth(bool) Option passed to a control to allow or disallow horizontal expansion.
GUILayoutOptionsInstance Height(float) Option passed to a control to give it an absolute height.
GUILayoutOptionsInstance MaxHeight(float) Option passed to a control to specify a maximum height.
GUILayoutOptionsInstance MaxWidth(float) Option passed to a control to specify a maximum width.
GUILayoutOptionsInstance MinHeight(float) Option passed to a control to specify a minimum height.
GUILayoutOptionsInstance MinWidth(float) Option passed to a control to specify a minimum width.
GUILayoutOptionsInstance Width(float) Option passed to a control to give it an absolute width.

Example

Most GUILayout and EditorGUILayout methods takes an optional "params GUILayoutOption[]" parameter. Each time you call this, an array is allocated generating garbage.

// Generates garbage:
GUILayout.Label(label, GUILayout.Label(label, GUILayout.Width(20), GUILayout.ExpandHeight(), GUILayout.MaxWidth(300)));

// Does not generate garbage:
GUILayout.Label(label, GUILayout.Label(label, GUILayoutOptions.Width(20).ExpandHeight().MaxWidth(300)));