Array to match Enum in Inspector

I’m making a serialized bool array, which should ideally be changeable in the inspector. It’s part of a class, Profile, that doesn’t inherit from MonoBehaviour. My WorldManager class has a public instance of Profile. Profile has an enum and some arrays like this:

public enum MathModule {Addition, Multiplication, Subtraction, Division, Exponents};
public bool[] mathEnabled = new bool[5];
public float[] minimum = new float[5];
public float[] maximum = new float[5];

And in the inspector, it looks like this:


It is not entirely necessary for me to look at it in the inspector, as the final product will have users editing them in GUI. But it’s nice to see what I’m looking at as I’m developing, and it will come in handy in other situations as well.

So far, the only other questions I can find on the topic are how to change enums at runtime. And maybe I could use a dictionary object, but that’s far less than ideal. I want to make an array that relates to the enum values, and shows those values in the inspector.

Making a subclass, MathModuleStats or something like that, makes more sense than I’m willing to admit at the moment, but I’m also looking for what to do when that doesn’t make sense.

What you need is a custom PropertyDrawer. Here’s one that does what you want.