Random color question

I have a script that gives me four random colors on a square(game object). I need the random colors not to duplicate on start.

I suggest you put the colors in the array, and randomise their order in the array: Randomize Array in C# - Unity Engine - Unity Discussions

Maybe something like this, don’t know if it works haven’t tested it:

void reshuffle(Color[] colors)
    {
        // Knuth shuffle algorithm :: courtesy of Wikipedia :)
        for (int t = 0; t < colors.Length; t++ )
        {
            Color tmp = colors[t];
            int r = Random.Range(t, colours.Length);
            colors[t] = colors[r];
            colors[r] = tmp;
        }
    }