Version 2.1.0.0

GUILayoutOptions class

Namespace: Sirenix.Utilities
Assembly: Sirenix.Utilities
public static class GUILayoutOptions

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

Inheritance
  • System.Object
  • GUILayoutOptions
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)));

Fields

EmptyGUIOptions
An EmptyGUIOption[] array with a length of 0.
public static readonly GUILayoutOption[] EmptyGUIOptions

Methods

ExpandHeight(Boolean)
Option passed to a control to allow or disallow vertical expansion.
public static GUILayoutOptions.GUILayoutOptionsInstance ExpandHeight(bool expand = true)
Parameters
System.Boolean expand

ExpandWidth(Boolean)
Option passed to a control to allow or disallow horizontal expansion.
public static GUILayoutOptions.GUILayoutOptionsInstance ExpandWidth(bool expand = true)
Parameters
System.Boolean expand

Height(Single)
Option passed to a control to give it an absolute height.
public static GUILayoutOptions.GUILayoutOptionsInstance Height(float height)
Parameters
System.Single height

MaxHeight(Single)
Option passed to a control to specify a maximum height.
public static GUILayoutOptions.GUILayoutOptionsInstance MaxHeight(float height)
Parameters
System.Single height

MaxWidth(Single)
Option passed to a control to specify a maximum width.
public static GUILayoutOptions.GUILayoutOptionsInstance MaxWidth(float width)
Parameters
System.Single width

MinHeight(Single)
Option passed to a control to specify a minimum height.
public static GUILayoutOptions.GUILayoutOptionsInstance MinHeight(float height)
Parameters
System.Single height

MinWidth(Single)
Option passed to a control to specify a minimum width.
public static GUILayoutOptions.GUILayoutOptionsInstance MinWidth(float width)
Parameters
System.Single width

Width(Single)
Option passed to a control to give it an absolute width.
public static GUILayoutOptions.GUILayoutOptionsInstance Width(float width)
Parameters
System.Single width

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.