StyleWith

Disposable scope wrappers that temporarily override a GUIStyle's border, margin, or padding for the duration of a using block. The original values are captured on construction and restored on disposal, ensuring style modifications never leak.

Architecture

spinner

Data Flow

spinner

Scopes

Scope
Factory Method
Style Property Modified

DrawGUI.StyleWithBorder(style, ...)

GUIStyle.border

DrawGUI.StyleWithMargin(style, ...)

GUIStyle.margin

DrawGUI.StyleWithPadding(style, ...)

GUIStyle.padding

Key Concept: Selective Overrides

All StyleWith scopes accept nullable int? parameters for left, right, top, and bottom. Only non-null values are overridden; null parameters keep the original value:

// Only override left padding, keep everything else
using (DrawGUI.StyleWithPadding(myStyle, left: 10))
{
    // myStyle.padding.left is 10, other padding values unchanged
}
// myStyle.padding.left is restored to original

See Also

Last updated