Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity C# enum, Unsupported type error

In Unity C#,
This enum code make errors on the console at runtime only.

[System.Flags]
private enum ActionSet : long
{
    Sit      = 0x0000000000000001,
    Stand    = 0x0000000000000002,
    Walk     = 0x0000000000000004,
    Sleep    = 0x0000000000000008,
    Run      = 0x0000000000000010,
    Happy    = 0x0000000100000000,
    Sleepy   = 0x0000000200000000,
    Gloomy   = 0x0000000400000000
}

The error is:

Unsupported enum type ‘Character.ActionSet’used for field 'blrah blrah' in class ‘Character’

Unity C# support int type only?
And no problem to use this code?

like image 854
Jinbom Heo Avatar asked Feb 25 '26 13:02

Jinbom Heo


1 Answers

The issue is Unity's enum serializer expects a 32bit value only. Some possible workarounds:

  • Use [NonSerialized] attribute.

  • Store the value in a underlying type (long in your example).

like image 128
gresolio Avatar answered Feb 28 '26 03:02

gresolio