When displaying a name of an enum item as a label, how do you replace an underscore with a space? because you must use an underscore for more that one word.
Iād actually recommend you have an array of names, such that you write:
name = myEnumNames[enumVal];
because:
- It is then easy to change they player-visible names without changing all your code: because you find a better name; to translate to other languages; because you need other characters like ā&ā.
- Better performance: enum string conversion is surprisingly convoluted.
If you really must, use string.Replace :
name = enumVal.ToString().Replace("_"," ");