Optimization Disclaimer

This post does come with a disclaimer though: do not optimize unless you absolutely have to! Optimization can go on forever, so only do it if there are noticeable issues in the existing code. Otherwise, you risk breaking old code, or at least introducing bugs, for no real payoff. And that doesn't even touch on the maintainability of optimized code.

Fortunately, Unity offers a built-in profiler that can be used to tell exactly where to optimize. Therefore, your optimization strategy should be something like:

Notice slowdown in your game. Use the profiler to pinpoint the exact cause of slowdown. Fix only that area, touching as little code as possible!

Now, in the event that you do have to optimize, here are a few tips to help.