public class Enemy: MonoBehaviour {
public enum Spells: int { Fireball, Lightning, ForcePush }
void CastSpell(Spells spell)
{
// in regular C# this is possible
print(String.Format(“{0} spell casted”, Enum.GetName(typeof(Spells), spell)));
}
}
How can I do something like this C# unity script?
hpjohn
2
Should work.
System.Enum.GetName(…)
2 Likes
I suspect you copied an example that had “using System” and forgot to include that bit at the top of your file.
Although in this case, you could presumably just use “spell.toString()” instead…
1 Like
Cool. Thank you.
VStudio imports by default the System namespace. MonoDevelop doesn’t by default.
Its a good lesson for me.