I think I get what you’re asking, but I’m still left asking “why?”:
Inspectors by default only draw for MonoBehaviour derivatives, because only a MonoBehaviour can be attached as a Component to a GameObject.
What you’re doing here is actually really going against Unity’s grain and you’re definitely making life harder for yourself.
The fact that you are calling a class “BaseAction” leads me to believe that it is the foundation class for a number of various actions that will be performed. In Unity, an “action” could probably be used synonymously with “behaviour” - which is why the whole MonoBehaviour class structure pretty much single-handedly drives Unity’s API. It just seems to me like you are needlessly reinventing the wheel on this, is all.
With that said - only MonoBehaviours can be shown in the Inspector, but you can use the Editor API to script out custom editors for each one of these classes.
If you were to stick with this route though, here’s probably the simplest way to do it:
-
LevelScript the MonoBehaviour has a property called action, which is a BaseAction. (The BaseAction class must be a SerializableAttribute)
-
Each additional action must extend BaseAction.
-
Use your custom inspector to set the value of the target LevelScript’s action to the class corresponding to the enum, remember to destroy old references.
-
Depending on the action that is selected, you can draw inspector fields to edit it’s properties. You can do this manually in a case switch because you will know what all the important properties are - or maybe use something like System.Reflection to traverse the class’s properties and spit out fields.
It’s a lot of work, which is why I suggest re-evaluating your approach to take advantage of Unity’s power.
[Edit]
The way I typically handle this Level Manager:
I will generally create an empty GameObject and name it “Managers” and I will attach various MonoBehaviour classes to this GameObject. (ie a class called LevelManager)
Then, any simple actions that are clearly defined will be attached to this same GameObject, or other GameObjects parented to the “Managers” (it depends on how many behaviours it needs) For instance I’ll have one for spawning enemies, pickups, etc. which has reference to the objects that need to be spawned and they will contain the encapsulated logic for spawning them.
The LevelManager will have a reference to all of these other managers, so all you have to do is communicate with the level manager to update data and get things happening.
It makes for very small management classes that only serve one purpose and are very maleable.
Hope that helps.
==
I'm not exactly sure what you're trying to achieve here. It seems like you are trying to create a script which then controls what other scripts run on your Game Object via an enum - am I correct in understanding this?
– equalsequalsGlad to see I was understanding. This actually kind of breaks Unity's convention of having a different behaviour per script. What you're doing is creating a script, which would have to be a MonoBehaviour and thus exist at run-time, be strictly an Editor object. Do you want to have all of these classes be behaviours of this game object and you're just switching, or do you only want one of these on there at a time and switching the enum value in your inspector would remove the old behaviour and replace it with a new one?
– equalsequals