- Home /
if you've selected this enum. do this. How?
Hey guys. I noticed, if you create an enum like this:
public enum Type
{
Player,
Enemy
}
public Type type = new Type();
You can see it in the inspector, and select the Player & Enemy. Now. Is there a way to an if statement, that checks if you've selected Player in the inspector?
something like this
if(Type.Player.isSelected == true)
{
//do stuff...
}
Comment
Best Answer
Answer by Wolfram · Feb 04, 2013 at 08:13 PM
if(type == Type.Player)
{
//do stuff...
}
You might be better off with a switch block if you're handling multiple possibilities:
switch(type)
{
case Type.Player:
//do stuff
break;
case Type.Enemy:
//do different stuff
break;
}
It's marginally more efficient than a series of if-else blocks.