Enum Flags: Everything option not working with unsigned integers

I have an enum flag, but when I select all the values or select the Everything option, it resets to None.

This seems to only affect unsigned integers, such as byte and ushort.

Is there a way I can disable this automatic behaviour, where selecting all values doesn’t just turn in to Everything (which is broken)?

My current workaround is to just create an extra flag, and create my own Everything flag which contains all flags but the extra one, like this:

[Flags]
    public enum LogType : byte
    {
        None = 0,
        All = User | System | Log | Warning | Assertion | Error,
        User = 1 << 0,
        System = 1 << 1,
        Log = 1 << 2,
        Warning = 1 << 3,
        Assertion = 1 << 4,
        Error = 1 << 5,
        ImJustHereCozUnityDumb = 1 << 6,
    }
1 Like

I just ran into the same problem, thanks for the work around, hope it is fixed at somepoint…

I’m assuming you’re using a custom inspector or property drawer. I ran into this same issue and filed a bug report. A Unity dev informed me that assigning the value to SerializedProperty.long instead of SerializedProperty.int will get around Unity automatically seeing the last bit of your uint as a negative value and converting it to 0 (because it thinks uints shouldn’t go negative.) My response was gratitude for the insight, but a request that the docs be updated to point out this little idiosyncracy. I hope that helps.

3 Likes