Insert enum breaking existing inspector values

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.

You can explicitly set the enum values:

public enum Foo {
	Dog   = 1,
	Snake = 3,
	Cat   = 7,
	Bird  = 5
}

Also adding Louis’s answer here, I can’t seem to vote up or mark a comment:

It might be possible to write a PropertyDrawer for your specific enum. Word of warning, though, I’ve been building up a giant generic Editor-GUI utility class and trying to genericize enums is some of the most hair-pullingly frustrating stuff. I dunno if that’ll present a problem with a PropertyDrawer, but you’ll probably need a separate PropertyDrawer for every enum you want to behave the right way, if you do go this route. -Louis