MeshRenderer.material.color not changing inside if statement but is outside if statement?

My problem is simple. I want a GameObject that will change color if you click it once, and change back if you click it again. Here is my code:

			if (Input.GetButtonUp ("Select")) {
				// A tile has been clicked!
				MeshRenderer hitRenderer = mouseRayHit.GetComponentInChildren<MeshRenderer> ();
				if (hitRenderer.material.color == Color.red) {
					hitRenderer.material.color = Color.white;
				}
				hitRenderer.material.color = Color.red;
			}

If I click it once, it will change to red, but it will not change back to white. This is confuzzling me very much. Is there some obscure thing about changing colors of instances of materials?

Uhm you unconditionally set the color to red at the end. So whenever this code snippet runs you always set the color to red. You probably want something like this:

if (Input.GetButtonUp ("Select"))
{
    MeshRenderer hitRenderer = mouseRayHit.GetComponentInChildren<MeshRenderer> ();
    if (hitRenderer.material.color == Color.red)
    {
        hitRenderer.material.color = Color.white;
    }
    else
    {
        hitRenderer.material.color = Color.red;
    }
}