- Home /
Unsupported enum type
Well heres my code for my enum.
enum PlayerDirection : sbyte
{
Left = -1,
Right = 1
}
whenever I run, everything works good, and I can Debug.Log the values by casting to int, although im getting these hardmless errors
Unsupported enum type: playerDirection
Unsupported enum type: Left
UnityEditor.DockArea:OnGUI()
Unsupported enum type: Right
UnityEditor.DockArea:OnGUI()
I've tried specifying System.NonSerializable, and I tried [HideInspector] but no luck. I've also tried take out the declaration for sbyte, and it still throws up the first error (but not the last two).
I need them stored this way so I can adjust movement based on direction (addforce (30 * playerDirection)) for example.
because i'm using this to deter$$anonymous$$e the math for the movement, but I'm also doing checks to it to see what direction the player is facing. I suppose I could use 3 variables (2 const's, left and right) and then a currDirection variable, but that would end up being 3 bytes ins$$anonymous$$d of 1. I'ts not a huge difference but its still a waste. this code works great, I just don't know why its throwing up that error.
Answer by eric21000 · Oct 29, 2013 at 10:08 AM
I had the same problem with uint enum. Unity seems to manage only int enum. Use int instead of sbyte and it should work.
Answer by flaviusxvii · Oct 22, 2013 at 04:33 PM
None of those 3 things it complains about are enum types. So everything looks great.
Could you explain a bit more please?
enum PlayerDirection : sbyte
{
Left = -1,
Right = 1
}