Color class not working?

Here is my script:

var randomize = false;

var object1 : GameObject;
var object2 : GameObject;
var object3 : GameObject;
var object4 : GameObject;
var object5 : GameObject;
var object6 : GameObject;
var object7 : GameObject;
var object8 : GameObject;
var object9 : GameObject;

private var inputColorIndex = 0;
private var orange = Color(1.0, 0.5, 0.0, 1.0);

if(randomize) Randomize();

function Update ()
{
	if(inputColorIndex != 0) Colorize(inputColorIndex);
	inputColorIndex = 0;
}


function Randomize ()
{
	objectIndex = 1;
	colorIndex = Random.Range(1, 8);
	
	while(objectIndex < 10)
	{
		object = PickObject(objectIndex);
		if(object)
		{
			object.renderer.material.color = PickColor(colorIndex);
			script = object.GetComponent(ColorCarry);
			if(script) script.index = colorIndex;
		}
		objectIndex ++;
	}
}

function Colorize (index : int)
{
	objectIndex = 1;
	
	while(objectIndex < 10)
	{
		object = PickObject(objectIndex);
		if(object)
		{
			object.renderer.material.color = PickColor(index);
			script = object.GetComponent(ColorCarry);
			if(script) script.index = index;
		}
		objectIndex ++;
	}
}

function PickObject (index : int)
{
	if(index == 1) return object1;
	if(index == 2) return object2;
	if(index == 3) return object3;
	if(index == 4) return object4;
	if(index == 5) return object5;
	if(index == 6) return object6;
	if(index == 7) return object7;
	if(index == 8) return object8;
	if(index == 9) return object9;
}

function PickColor (index : int)
{
	if(index == 1) return Color.white;
	if(index == 2) return Color.yellow;
	if(index == 3) return Color.red;
	if(index == 4) return Color.blue;
	if(index == 5) return Color.green;
	if(index == 6) return Color.cyan;
	if(index == 7) return Color.magenta;
	if(index == 8) return orange;
}

I get these errors:

www.yoggy.bluegillweb.com/errors.png

What is wrong here? Seems like it should work: http://unity3d.com/Documentation/ScriptReference/Color.html

I’d say the latter errors result from the first one, since I have used Color.magenta etc. just fine.

Not sure what the original problem is. Maybe try this?

private var orange : color = Color(1.0, 0.5, 0.0, 1.0);

Or declare the var first, and then later give it its starting value?

The bug is that your script Color.js conflicts with UnityEngine.Color. The bug with Unity is that it doesn’t report this mistake clearly.

-Jon

That’s some good detective work!

Yep, it was a naming problem. oops.