- Home /
Color variable matching
Hi,
I'm having a problem where my variables of "Color" don't match.
This works:
var variable= Color.green;
switch(variable){
case Color.green: Debug.Log("Works"); break;
}
This does not work:
var variable= Color(0.5, 1, 0.5, 1);
switch(variable){
case Color(0.5, 1, 0.5, 1): Debug.Log("Doesn't work"); break;
}
I tried turning Color(0.5, 1, 0.5, 1) into a static variable, but that didn't change anything. Is there something simple I'm missing?
Comment
Answer by GesterX · Feb 09, 2011 at 09:46 AM
I created a script using your second chunk of code and it worked fine.
I just placed the code in an update function and it repeatedly printed "Doesn't Work" which is the expected behaviour. There must be something else preventing this code from executing.
Your answer
