RGB Colours :/

argh! hi guys, im not sure what im doing wrong here…

im trying to use RGBA but cant get it working… any ideas?

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {

    public Color32[] values;
    public int i=6;
    
    void Start() {
        foreach (Color32 value in values) {
            print(value);
        }


        values = new Color32*;*

values[0] = Color32(1,1,1,1);
values[1] = Color32(1,1,1,1);
values[2] = Color32(1,1,1,1);
values[3] = Color32(1,1,1,1);
values[4] = Color32(1,1,1,1);
values[5] = Color32(1,1,1,1);
}

}

What exactly are you trying to do?

You are printing something which is not assigned yet. So you’ll see nothing printed. The foreach loop should be after your assignments.

And you have to use “new”:

value[0] = new Color32(1, 1, 1, 1);

The way to define a new struct value is still to pass through its constructor:

values[0] = new Color32(1,1,1,1);

Add “new”.

Also note your use of Color32. The documentation reads:

Each color component is a byte value with a range from 0 to 255.

Components (r,g,b) define a color in RGB color space. Alpha component (a) defines transparency - alpha of 255 is completely opaque, alpha of zero is completely transparent.

You’re getting a very transparent almost-black with (1,1,1,1)

You have to assign like this

value[1] = new Color32(1,1,1,1);