The ColorPalette
system is designed to allow artists to easily create a custom palette of colors and name or tag them within Unity. These colors can be accessed in scripts through their names or tags.
The ColorPalette
is a ScriptableObject that holds a collection of ColorPaletteEntry
objects. Each entry represents a named color.
- Right-click in the Project panel.
- Select Create > ScriptableObjects > ColorPalette.
- Name the new ColorPalette asset.
- Select the ColorPalette to edit it in the Inspector.
- Add, edit, or remove color entries as needed.
Use the GetColor(string name)
method to retrieve a color by its name or tag.
Color color = colorPalette.GetColor("TagName");
This class defines a color entry within the ColorPalette
. It includes two public fields:
ColorName
: The name of tag of the color.Color
: The color itself.
These fields can be edited directly within the Unity inspector when editing a ColorPalette
.
- Colors cannot be added to the palette at runtime in the editor.
- Changes to colors in the palette while the game is running in the editor will be reflected in real time, but will revert to their original values when the games stops. This behaviour is consistent with Unity's handling of all game objects and is not specific to the
ColorPalette
system.