I have a method which sets a range of base colors in an array.
I then want to set a range of corresponding colors, with 50% alpha, via another method.
I realise I can manually set the alpha against each base color, but because my base color array may grow to numerous colors, I thought it would save hassles in future to get the 50% alpha colors in a method. rather than me typing them all in.
public Color[] colorBase = new Color[6];
public Color[] colorWithAlpha = new Color[6];
void Start() {
SetBaseColors();
SetColorsWithAlpha();
}
void SetBaseColors() {
colorBase[0] = Color.cyan;
colorBase[1] = Color.red;
colorBase[2] = Color.green;
colorBase[3] = Color.blue;
colorBase[4] = Color.yellow;
colorBase[5] = Color.magenta;
}
// the below doesn’t work:
void SetColorsWithAlpha() {
Color theColor;
for (int i = 0; i < colorBase.Length; i++) {
theColor = colorBase*.maxColorComponent;*
colorWithAlpha_.a = theColor * 0.5f;_
* }*