I am creation a color selector for selecting the color you want an object to be by name, it is for kids so I want very specific color names and matching colors.
// —I created an enum full of colors—
public enum theColors
{
black,
blue,
brown,
green,
red,
purple,
yellow,
orange,
grey,
white
}
//---- And then I added a procedure for selecting the color ----
public Color GetColor(theColors aColor)
{
switch (aColor) {
case theColors.black:
return new Color(0,0,0);
case theColors.blue:
return new Color(0,0,255);
case theColors.brown:
return new Color(165,42,42);
case theColors.green:
return new Color(0,255,0);
case theColors.red:
return new Color(255,0,0);
case theColors.purple:
return new Color(160,32,240);
case theColors.yellow:
return new Color(255,255,0);
case theColors.orange:
return new Color(255,165,0);
case theColors.grey:
return new Color(165,165,165);
case theColors.white:
return new Color(255,255,255);
default:
return new Color(0,0,0);
}
}
//---- Then when I wish to use the color, I simply apply it thus ----
renderer.material.color = GetColor(newColor);
The problem is that only some of the colors will apply, black, white, grey, blue, red, yellow, all work.
Brown and purple and orange do not. Why?