How do I show a variable in my base class in the inspector?

I have two classes, BaseClass → DerivedClass;

public class BaseClass : MonoBehaviour {
public Enum baseVariable;
}

public class DerivedClass : BaseClass {
public Enum derivedVariable;
}

derivedVariable is visible in the inspector, but baseVariable is not. How do I make it visible?

Edit: It actually works fine with ints. I was just trying to simplify my code for the question. In my actual code, I use Enums, and I’m guessing it can’t display the Enums because they are declared in the derived class.

Your code works, just with an error: MonoBehaviour, not MonoBehavior.

Variables don’t show up correctly in editor until the code compiles without any errors. Eliminate errors and all public variables will show up, no matter how many levels of inheritance.

It looks like Unity can’t display a generic Enum variable. It has to know the type of the enum.

For example, if I have an enum State

public enum State {
Idle, Walking, Jumping
}

Then this will be displayed in the inspector:

public State currentState;

But this won’t:

public Enum currentState;

Put [system.serializable] above the derived class definition