Hello everyone,
I know I can get a random enum of a specific range of enums. For example (Difficulty is the enum): currentDifficulty = (Difficulty)Random.Range(0, 3);
Now I want to get a random enum of some sort of a list (or array) of specific enums (not all enums and not a range). For example: I want to get a random enum off this array of enumA, enumC, enumD, enumE, enumR and enumT. How do I approach that?
Thank you @Errorsatz for the quick answer! Unfortunately I don’t understand your example completely (especially line 1). Where would I put the enums? At options? Thank you very much
The function above will throw an IndexOutOfBounds exception if you give it an empty array, incidentally. You could add a check to throw a more specific error or return a default value.