Color not being set in Javascript

The code below should change the color in the variable, don’t you think?

private var c_previous_color : Color = Color.black;

function Start () {
    c_previous_color == Color.black;
    Debug.Log("c_previous_color=" + c_previous_color + "       " + Random.Range(0, 100000));

    c_previous_color == Color(0.5, 0.5, 0.5, 0);
    Debug.Log("c_previous_color=" + c_previous_color + "       " + Random.Range(0, 100000));

    c_previous_color == Color.red;
    Debug.Log("c_previous_color=" + c_previous_color + "       " + Random.Range(0, 100000));
}

(I added the Random.Range so that each Debug.Log statement would be different and would therefore show up in the log.)

The log file shows this:

c_previous_color=RGBA(0.000, 0.000, 0.000, 1.0000) some random number here
UnityEngine.Debug:Log(Object)
c_previous_color=RGBA(0.000, 0.000, 0.000, 1.0000) some random number here
UnityEngine.Debug:Log(Object)
c_previous_color=RGBA(0.000, 0.000, 0.000, 1.0000) some random number here
UnityEngine.Debug:Log(Object)

So the color is not being changed. What am I doing wrong? :?

= is for assignment, == is for comparison.

–Eric

D’oh! :sweat_smile: I know that! I’ve been programming for 17 years… Guess I had a noob moment.

Thanks Eric5h5!

I’d be surprised if there’s anyone who hasn’t done that at one time or another…

–Eric