What are some good ways to optimize my game's performance?

What are some good ways to optimize my game's performance?

This checklist is based on my answer relating to porting games to iPhone, however the points are all valid as general Mac/PC optimisation tips too.

In general, this question covers a huge area, so you should look up and research each of these concepts individually:

  • First and foremost - identify what needs optimising. Use the built in profiler.

  • Reduce poly count and draw calls right down. For PC/Mac/Web, aim for 200-400. For iPhone, I've heard reports of 70 draw calls running at a good speed, but really you probably want to aim for less than half that if you'll also have any significant physics and scripting in your game.

  • Use pools of reusable objects, rather than instantiating large amounts of new objects during play

  • Avoid physics that involve many objects clumping together

  • Increase the physics timestep as high as is tolerable, if physics is a bottleneck

  • Fewer lights means better performance (at least until the deferred rendering features coming in 3.0!) so, use baked lightmaps instead of realtime lights where appropriate.

  • Pack as much as you can together into texture atlases, to maximise material sharing.

  • Use built-in arrays rather than dynamic arrays

  • Cache references to everything that you possibly can (eg, components), to avoid lookups during play

  • For really speed-critical tasks, manipulate many small objects from a central controller, rather than many small Update()'s

  • For 2d sprites, use sprites combined into a single mesh (a la [SpriteManager][1])

  • Use a single combined mesh with bones to animate the positions of separated submeshes as if they are separate objects.

  • Because Mac/PC hardware can vary so much in performance, it's good to create an adaptive degradation routine, which turns off various expensive graphical features dynamically based on the current average frames per second reading. I do this in all my games and it works well. (eg, step up and down through the quality settings, switch to simpler shaders, etc). There's an example of this in the island demo.

Edit by Jamora:

Here’s what Unity has to say about optimizing:

Optimizing Graphics Performance

Practical Guide to Optimization for Mobiles

watch videos of different unite sessions about optimization. you can do different things dipending on your game. you can make your code faster and memory footprint lower. you can optimize your assets too.