Switching things up in Unity.

A series of if..else statements.

Have you been using something like the above when you have several things to choose between in your code? This is okay and manageable when you only have 2 or maybe three options at most. But what about when you start having half a dozen, or 20, or even 100? Then things can get pretty hairy and hard to read.

There is another option. You can use a switch statement. A switch statement serves the same purpose as…