Use Array values in enum

I am creating a spawn system for use in the inspector, i want to load all the prefabs from the resources folder and then use them as options in an enumerator so the user can choose what to spawn.

How can I use values from an array in an enumerator ? Any help would be greatly appreciated.

You can cast Enums to int and back

PrefabEnum certainEnum = (PrefabEnum )3;
int intValue = (int)PrefabEnum.SharkPrefab;

So you could make an array where you drag the prefabs and then just index it with you Enum cast to int.

This way you would have to manually match the indexes to enum values though. So unless you have hundreds of prefabs in the array (so many that looping is not an option because of performance), it might be easier to maintain a system where each prefab you make is assigned a variable telling which enum it corresponds to, and then you’d make a method that uses the enum value to loop the array until it finds the prefab with matching value.