Modifying Enumerator Values via Inspector Prior to Runtime

Hi all,

I have a question regarding the possibility of modifying the contents of an enumerator using the inspector window. I want to store accessible controls/settings as an enumerator value to determine what control/setting is being referenced when I make calls in game, but for ease of use I’d like to pair the contents of a database that stores scriptable objects in an array to the available enumerator values. These scriptable objects store common data that is specific to settings/controls such as the enumerator value as a variable to dictate what input/setting is being called (To be clear, settings and controls are separate but I want to utilize the same concept for both).

Currently, I define the enumerator values as well as the database and setting/input objects manually but I wanted to see if I could link/modify the contents of the enumerator prior to run-time based on the contents of the scriptable object array on the database using something like OnValidate(). The name for each enumerator value would be derived from a string variable on the scriptable objects. Does anyone have any suggestions or Unity documentation links for accomplishing something like this? Or even if it is not possible/recommended, I would appreciate any insight.

Can you explain what you mean by “enumerator” in this context?

Are you talking about Enums/Enumerations?

Yes, Enums/Enumerations, for example I represent my GameInputs like this:

enum GameInput
{
    PrimaryAction,
    SecondaryAction,
    MoveForward,
    MoveBackward,
    MoveLeft,
    MoveRight
}

In case my question was poorly worded, put simply I want to alter the values within my Enum prior to runtime based on what is stored in an array found on a database defined in the inspector. The context is that I am allowing users to declare their in-game inputs via this database but I do not want to have to modify/update the Enum seperately and would prefer it to be a single, straight forward process.

There is no way to modify the source code via database entries. You must simply go with a data-driven approach rather than using the enum.