Showing posts with label Enum. Show all posts
Showing posts with label Enum. Show all posts

Tuesday, 24 September 2013

How to use enums to store keys for scripts in Unity3D

Everyone love strings. Especially those hard-code when you can find all references to this one which you're looking for...
How much I love reading such code and often fix it... This is almost the best thing after magic-classes with thousands of lines and no comments.

<Sarcasm off>

But lets back to the our topic...

What is "enum"? And why should I use it?

Enumerated type (in short enum) is a data type consisting of named constant values. (from Wikipedia).
For example
enum Days {Mon, Tue, Wed, Thu, Fri, Sat, Sun};