I would like to create an enum based on a base class’s children.
For instance, I have a bunch of weapon classes that all extend from a single weapon base class. I have a script which acts as a pickup for weapons and/or ammo, based on inspector settings.
I would like to automatically create an enum that specifies which weapon that the pickup will modify so it would be easy for the level designer in our group to place what pickups he wants in the level, just by changing the enum in the inspector.
I would like the enum to be generated automatically, so that new weapons can be created without needing to worry about adding or removing from the enum manually.
Note that I do NOT need this to be modified at runtime.
Here’s an example of my class structure: (I tried to format it in an easy to visualize way)
abstract GunBase : Monobehaviour
abstract GunRay : GunBase
- public Pistol : GunRay (This should be in the enum)
- public Rifle : GunRay (This should be in the enum)
- public Shotgun : GunRay (This should be in the enum)
abstract GunPrefab : GunBase
- public RPG : GunPrefab (This should be in the enum)