Cube Random Color

Hey community,

I have a little question there. I want to change the color of my cube every 3 seconds to one of these colors random (red, blue , green) How can I code this in C#? Ive already created the timer just need the code for changing the color randomly.

Thanks.

I want to change it random.

public Color[] colors = new Color[] {
            Color.red, Color.blue, Color.green
        }

public Color GetRndColor() {
        int index = UnityEngine.Random.Range(0, colors.Length-1);
        return colors[index];
    }
1 Like
        if (mTimer > 0) {
            mTimer -= Time.deltaTime;
        }

        if (mTimer <= 0) {
            Debug.Log ("Test");
            mTimer = TimeReset;
        }

How can I intigrate this code from above?