Adding elements to an enum at runtime

Is it possible to add elements to an enum at runtime?

Enums are almost always used to help read if/switch logic. Something like:

enum doorType { open, closed, locked, broken, UNKNOWN };

if(door1.status == doorType.locked) { 
  AddMessage("Locked"); PlaySound(knobJiggle); }
else if(door1.status == doorType.closed) {
  door1.status=doorType.open; door1.animation.Play("opening"); }

If you wanted to add a new value, like gluedShut, you’d need to add new ifs to handle it, so adding at runtime wouldn’t be very helpful. If you want something you can add to, try an array, List or Dictionary. Can then say things like myStuff.Add("hammer");

simple answer is no… you can’t do it

enum is jus like class or struct … do u think it is possible to add a new member or function to a class at run time??

also enums are supposed to be a complete static enumeration. Even it is possible to do it… i dont think it is worth all the effort?!! Are u just trying out of ur intrest?!

here is is a good link on this sort of idea

https://stackoverflow.com/questions/2779743/can-you-add-to-an-enum-type-in-run-time

hope it helps.

Here is youtube tutorial how to show List as Enum in inspector
158744-gif.gif
https://www.youtube.com/watch?v=ThcSHbVh7xc