In this chapter, we have introduced some extra features and a range of approaches to improve game performance and collect performance data for analysis.
The first three recipes in this chapter provide some ideas for adding some extra features to your game (pausing, slow motion, and securing online games). The rest of the recipes in this chapter provide examples of how to investigate and improve the efficiency and performance of your game.
Just as there are many components in a game, there are many parts of a game where processing bottlenecks may be found and need to be addressed to improve overall game performance. Some additional suggestions and further reference sources are now provided to provide a launching pad for your further exploration of the issues of optimization and performance, since such topics could take up a whole book rather than just one chapter.
Mobile devices have considerably less memory and processing resources than consoles, desktops, or even laptops, and often raise the biggest challenges when it comes to game audio. For example, the iPhone can only decompress one audio clip at a time, so a game may suffer processing spikes (that is, slow down game frame rate) due to audio decompression issues.
Paladin Studios recommend the following audio file compression strategies for mobile games:
For more information about this topic, see the following:
http://www.paladinstudios.com/2012/07/30/4-ways-to-increase-performance-of-your-unity-game/
For some strategies relating to physics, you might consider to improve performance the following:
FixedUpdate()
method call to reduce physics:Some code strategies you might consider to improve performance include the following:
Update()
or inner loops, and you can have objects set up a public static
variable to allow quick instance retrieval, rather than using a Find(…)
method. Or you could use the Singleton design pattern.OnGUI()
, since it is called every frame just like Update()
; this is much easier to avoid now with the new Unity 5 UI system.Here are several other sources that you might want to explore to learn more about game optimization topics:
http://x-team.com/2014/03/unity-3d-optimisation-and-best-practices-part-1/
http://www.codeproject.com/Articles/804021/Unity-and-Csharp-Performance-Optimisation-tips
http://docs.unity3d.com/Manual/OptimizingGraphicsPerformance.html
http://docs.unity3d.com/Manual/iphone-Optimizing-Physics.html
Here are several articles discussing Donald Knuth's famous quotation about premature optimization being "evil":
http://joeduffyblog.com/2010/09/06/the-premature-optimization-is-evil-myth/
http://stackoverflow.com/questions/385506/when-is-optimisation-premature
18.118.198.83