In every other language that I have used with enums, the enum values are simply constants for numeric values that can be used for anything where a number can be used. However, Unity doesn't like it when using an enum value in math. Consider this:
enum Dir { N, E, S, W };
function lookInDirection(dir:Dir) { var angle:int = dir * 90; // This fails. transform.eulerAngles = Vector3(angle,0,0); }
Is it possible to get the literal value of an enum value (in Javascript)? I saw somewhere that in C# you could simply cast it by using (int)dir, but that doesn't seem to work in Javascript. The following code gives a different error in Javascript:
var angle:int = (dir as int) * 90;