HorizontalLayout

DrawGUI scope that wraps EditorGUILayout.BeginHorizontal/EndHorizontal into a disposable using block. Arranges child elements in a horizontal row with optional style and layout options.

Definition

Namespace: Paragon.Editor Assembly: Paragon.Editor.dll

public static partial class DrawGUI
{
    public static Scope HorizontalLayout(params GUILayoutOption[] options)
    public static Scope HorizontalLayout(GUIStyle style, params GUILayoutOption[] options)
    public static Scope HorizontalLayout(this Scope scope, params GUILayoutOption[] options)
    public static Scope HorizontalLayout(this Scope scope, GUIStyle style, params GUILayoutOption[] options)

    private class HorizontalLayoutScope : Scope
}

Remarks

This file contributes factory and extension methods to the DrawGUI partial class, plus a private nested HorizontalLayoutScope implementation. The scope calls EditorGUILayout.BeginHorizontal on construction and EditorGUILayout.EndHorizontal on disposal.

When no GUIStyle is provided, GUIStyle.none is used as the default.

Quick Lookup

Goal
How

Basic horizontal layout

using (DrawGUI.HorizontalLayout()) { ... }

With style

using (DrawGUI.HorizontalLayout(myStyle)) { ... }

With layout options

using (DrawGUI.HorizontalLayout(GUILayout.Height(30))) { ... }

Chain onto another scope

using (DrawGUI.VerticalLayout().HorizontalLayout()) { ... }

Chain with style

using (scope.HorizontalLayout(myStyle, GUILayout.Width(100))) { ... }

Factory Methods

Standalone

Signature
Description

HorizontalLayout(params GUILayoutOption[])

Creates a horizontal layout with GUIStyle.none

HorizontalLayout(GUIStyle, params GUILayoutOption[])

Creates a horizontal layout with the specified style

Extension (Chaining)

Signature
Description

HorizontalLayout(this Scope, params GUILayoutOption[])

Pushes a horizontal layout onto an existing scope

HorizontalLayout(this Scope, GUIStyle, params GUILayoutOption[])

Pushes a styled horizontal layout onto an existing scope

Returns: Scope — the root scope (for standalone) or the parent scope with the new scope pushed (for chaining).

HorizontalLayoutScope (private)

Member
Description

style

GUIStyle — the layout style

options

GUILayoutOption[] — layout options (width, height, etc.)

OnBegin()

Calls EditorGUILayout.BeginHorizontal(style, options)

OnEnd()

Calls EditorGUILayout.EndHorizontal()

Examples

Side-by-Side Labels

Styled Row with Fixed Width

Chained with Vertical Layout

See Also

Last updated