Colorize

Scope that temporarily changes Unity's IMGUI color state. Supports three modes: full color (GUI.color), background only (GUI.backgroundColor), or label/content only (GUI.contentColor). The original color is captured on construction and restored when the scope is disposed.

Definition

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

public static partial class DrawGUI
{
    // Factory methods
    public static Scope Colorize(Color color)
    public static Scope ColorizeBackground(Color color)
    public static Scope ColorizeLabel(Color color)

    // Extension methods (chaining)
    public static Scope Colorize(this Scope scope, Color color)
    public static Scope ColorizeBackground(this Scope scope, Color color)
    public static Scope ColorizeLabel(this Scope scope, Color color)

    // Implementation
    private class ColorizeScope : Scope
}

Remarks

The ColorizeScope uses a bitmask mode byte to select which color property to modify:

Mode
Binary
Property

Full color

0b11

GUI.color — affects both background and content

Background

0b01

GUI.backgroundColor — background tint only

Label

0b10

GUI.contentColor — text and icon tint only

The original color is captured in the constructor before Begin() is called, then restored in OnEnd().

Factory Methods

Colorize

Temporarily sets GUI.color (affects both background and content).

ColorizeBackground

Temporarily sets GUI.backgroundColor (background tint only).

ColorizeLabel

Temporarily sets GUI.contentColor (text and icon tint only).

Parameter
Type
Description

color

Color

The color to apply for the scope's duration

Common Pitfalls

circle-exclamation
circle-info

Colorize affects everything. GUI.color multiplies with both backgroundColor and contentColor. If you only want to tint text, use ColorizeLabel. If you only want to tint backgrounds, use ColorizeBackground.

Examples

Tint All Content

Tint Background Only

Chain with Other Scopes

Conditional Colorization

See Also

Last updated