[SerializeField] Color not showing in the Inspector

I have the following piece of code in my class:

        [SerializeField] private TerrainType[] _terrainTypes = new TerrainType[]
        {
            new("Ocean2", 0.4f, new Color(31, 63, 127, 255)),
            new("Land", 0.9f, new Color(63, 255, 63, 255)),
            new("Snow", 1.0f, new Color(255, 255, 255, 255))
        };

...

[Serializable]
public struct TerrainType
{
    public string Name;
    public float Height;
    public Color Color;
  
    public TerrainType (string name, float height, Color color)
    {
        Name = name;
        Height = height;
        Color = color;
    }
}

When I run it, the name and height properties are showing just fine, but the colors are all white for all three colors. Any idea how I can resolve this, so all three color values are correct and show the proper color in the inspector? Here’s how it looks now:

Investigate the subtle difference between Color() and Color32() internal values. :slight_smile:

(I did this same thing a few times when I first got to Unity a decade or so ago.)

1 Like

Subtle indeed … but good to know the difference, and I got it working now. Thanks for pointing this out!

1 Like