Table of Contents

Class ColorPicker

Namespace
Godot
Assembly
GodotSharp.dll

A widget that provides an interface for selecting or modifying a color. It can optionally provide functionalities like a color sampler (eyedropper), color modes, and presets.

Note: This control is the color picker widget itself. You can use a ColorPickerButton instead if you need a button that brings up a ColorPicker in a popup.

public class ColorPicker : VBoxContainer, IDisposable
Inheritance
ColorPicker
Implements
Inherited Members

Constructors

ColorPicker()

public ColorPicker()

Properties

CanAddSwatches

If true, it's possible to add presets under Swatches. If false, the button to add presets is disabled.

public bool CanAddSwatches { get; set; }

Property Value

bool

Color

The currently selected color.

public Color Color { get; set; }

Property Value

Color

ColorMode

The currently selected color mode. See ColorPicker.ColorModeType.

public ColorPicker.ColorModeType ColorMode { get; set; }

Property Value

ColorPicker.ColorModeType

ColorModesVisible

If true, the color mode buttons are visible.

public bool ColorModesVisible { get; set; }

Property Value

bool

DeferredMode

If true, the color will apply only after the user releases the mouse button, otherwise it will apply immediately even in mouse motion event (which can cause performance issues).

public bool DeferredMode { get; set; }

Property Value

bool

EditAlpha

If true, shows an alpha channel slider (opacity).

public bool EditAlpha { get; set; }

Property Value

bool

HexVisible

If true, the hex color code input field is visible.

public bool HexVisible { get; set; }

Property Value

bool

PickerShape

The shape of the color space view. See ColorPicker.PickerShapeType.

public ColorPicker.PickerShapeType PickerShape { get; set; }

Property Value

ColorPicker.PickerShapeType

PresetsVisible

If true, the Swatches and Recent Colors presets are visible.

public bool PresetsVisible { get; set; }

Property Value

bool

SamplerVisible

If true, the color sampler and color preview are visible.

public bool SamplerVisible { get; set; }

Property Value

bool

SlidersVisible

If true, the color sliders are visible.

public bool SlidersVisible { get; set; }

Property Value

bool

Methods

AddPreset(Color)

Adds the given color to a list of color presets. The presets are displayed in the color picker and the user will be able to select them.

Note: The presets list is only for this color picker.

public void AddPreset(Color color)

Parameters

color Color

AddRecentPreset(Color)

Adds the given color to a list of color recent presets so that it can be picked later. Recent presets are the colors that were picked recently, a new preset is automatically created and added to recent presets when you pick a new color.

Note: The recent presets list is only for this color picker.

public void AddRecentPreset(Color color)

Parameters

color Color

ErasePreset(Color)

Removes the given color from the list of color presets of this color picker.

public void ErasePreset(Color color)

Parameters

color Color

EraseRecentPreset(Color)

Removes the given color from the list of color recent presets of this color picker.

public void EraseRecentPreset(Color color)

Parameters

color Color

GetPresets()

Returns the list of colors in the presets of the color picker.

public Color[] GetPresets()

Returns

Color[]

GetRecentPresets()

Returns the list of colors in the recent presets of the color picker.

public Color[] GetRecentPresets()

Returns

Color[]

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

Events

ColorChanged

Emitted when the color is changed.

public event ColorPicker.ColorChangedEventHandler ColorChanged

Event Type

ColorPicker.ColorChangedEventHandler

PresetAdded

Emitted when a preset is added.

public event ColorPicker.PresetAddedEventHandler PresetAdded

Event Type

ColorPicker.PresetAddedEventHandler

PresetRemoved

Emitted when a preset is removed.

public event ColorPicker.PresetRemovedEventHandler PresetRemoved

Event Type

ColorPicker.PresetRemovedEventHandler