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:
