Version 2.1.0.0

Odin has a dedicated attribute overview with examples

ColorPaletteAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
public sealed class ColorPaletteAttribute : Attribute, _Attribute

ColorPalette is used on any Color property, and allows for choosing colors from different definable palettes.

Use this to allow the user to choose from a set of predefined color options.

Inheritance
  • System.Object
  • System.Attribute
  • ColorPaletteAttribute
Remarks

See and edit the color palettes in Tools > Odin Inspector > Drawers > Color Palettes.

note

The color property is not tied to the color palette, and can be edited. Therefore the color will also not update if the ColorPalette is edited.

Example

The following example shows how ColorPalette is applied to a property. The user can freely choose between all available ColorPalettes.

public class ColorPaletteExamples : MonoBehaviour
{
    [ColorPalette]
    public Color ColorOptions;

    [ColorPalette("Underwater")]
    public Color UnderwaterColor;

    [ColorPalette("Fall"), HideLabel]
    public Color WideColorPalette;

    [ColorPalette("My Palette")]
    public Color MyColor;

    [ColorPalette("Clovers")]
    public Color[] ColorArray;
}

Constructors

ColorPaletteAttribute()
Adds a color palette options to a Color property.
public ColorPaletteAttribute()
ColorPaletteAttribute(String)
Adds color options to a Color property from a specific palette.
public ColorPaletteAttribute(string paletteName)
Parameters
System.String paletteName

Name of the palette.

Fields

PaletteName
Gets the name of the palette.
public string PaletteName
ShowAlpha
Indicates if the color palette should show alpha values or not.
public bool ShowAlpha