gsrour
January 18, 2013, 5:29am
1
hello
i am trying to create a simple function to change color instead of using :
renderer.material.color = Color.red;
in my script i typed this :
var red = Color.red;
var black = Color.black;
function ChangeColor(colorRef : Color)
{
if(colorRef == red)
{
renderer.material.color = red;
}
else if (colorRef == black)
{
renderer.material.color = black;
}
}
function Update ()
{
ChangeColor(red);
}
I am getting errors ?
Why ?
aixaix
January 18, 2013, 5:46am
2
Could you also post the errors you get?
gsrour
January 18, 2013, 6:04am
3
i figured out it seems it is case sensitive issue. i typed ChangeColor(Red); instead of ChangeColor(red);
is it possible to make it case non sensitive ?
also it it possible to make an else statement, if user typed anything else different than “red” or “black”. Do this Below in the debug :
Debug.Log(“Color does not exist !”);
Thx
gsrour:
i figured out it seems it is case sensitive issue. i typed ChangeColor(Red); instead of ChangeColor(red);
is it possible to make it case non sensitive ?
also it it possible to make an else statement, if user typed anything else different than “red” or “black”. Do this Below in the debug :
Debug.Log(“Color does not exist !”);
Thx
I think you could add another else with the Debug.log line so if itsnt one of another it doesnt exists