Magic strings in Unity 3D

I've been slowly dying inside whenever I see a tag referenced in C# script examples using a magic string, e.g. "Enemy". I wonder what would happen if you decided to refactor and you then wanted to change "Enemy" to "NPCs"?

I personally would want to create an enum with some backing string value, so that if I want to rename my layer, I only have to change it in 2 places, instead of however many places it's used.

How do you deal with this?


Sign In or Register to comment.