Color palette system that works in code and inspector?

Godot Version



Here’s my dream solution:

  • I make a script that contains a list of Color variables, exposing them to the inspector
  • Any other script can access those colors, to keep a consistent, easy to change color palette throughout the game
  • Whenever I set a color in the inspector, I can choose a color from the palette instead of an “actual” color, which will also update when I update the palette

Is there a way to achieve this? If not, what’s the closest I can get?

There are two parts to this that I found so far:

  1. Defining the colors and being able to set them in the inspector. It doesn’t seem to be possible to @export global variables. My first thought was to use a class_name with static variables, but those cannot be @exported. No variation I tried worked (@export static const, etc.) I could use an autoload script but I don’t think its variables can be @exported either?
  2. Accessing the colors in the inspector. I learned that the color picker actually has its own color palette system. But it’s rather underdocumented, or I haven’t been able to find good documentation for it. Is it possible to access those colors from code, and do they automatically update throughout the game if you change a color?

Sounds like a plugin/tool…
This sounds similar to what you want. you can find it on asset library too.