Enums are great, but unfortunately when used as fields that can be changed in the inspector they are completely dependent on the order of the enum in the code. I find it curious that Unity does not have an internal level of indirection for enum values from one script build to the next, so that you can insert new values anywhere into an enum without breaking all the existing fields that have values set.
Edit: It’s also worth it to note that I would like the enum values to remain consecutive as the integer values will be bit packed tightly with other values during the runtime.
Is there a C# attribute or something that would help me here? Some other kind of field? Any way to make these more useful in the Unity inspector? I could totally write a custom inspector to do this, but writing a custom inspector for every single component that uses an enum doesn’t seem like an efficient use of my time.
Here’s some simple code just to illustrate exactly what I’m talking about
public enum Foo
{
A,
B,
C
}
Then you change it to
public enum Foo
{
A,
NewValue,
B,
C
}
Thanks.