Is it possible to check the length of an enum?
Suppose I have some arbitrary enum, and I'm trying to generate a random value from it. It's trivial to accomplish this with a static cast and a hardcoded random int:
However, this requires me to keep excruciating track of every place I use this logic in, and manually change the range I feed FMath whenever I modify the enum. Is there any way I can manually check the exact number of possible values an enum has, instead of hard-coding it every time?
Why not create a static function as such:
And that's all you have to call when you need a random
Follow this question
Once you sign in you will be able to subscribe for any updates here