Hi folks,
I have met several puzzle while optimizing our project for iOS:
Our current project is a 2D arcade game with a lot of spawns, popping score texts(using SpriteText from Sprite Manager 2) and repeating sfx. We recently added a lot of sfx and music into the game and finished the sound scripting, since then the performance dropped quite a lot and we have to put a lot of effort into optimization.
We searched the forum upside down, we use every mentioned optimization method such as pre-allocated heap, use object pools to eliminate instantiate at runtime, cache component in a variable, use ToString() instead of String.Format, reduce file size of audio and texture assets, etc.
Q1.
But the “used heap” number in internal profiler still gets up quickly every tick. Are there any other allocation that can be prevent in scripting? We seems to have done enough except for convert an int value to a string so we can display a popping score on screen. But it seems that this kind of allocation is inevitable, is that true?
Q2.
Also our game runs much smoother on iPad compare to iPhone4. How’s that possible? Does that have something to do with iPhone4 having more memory available so when garbage collection happens it takes out more trash than iPad does? But from reading internal profiler I can’t confirm that, both device takes out about 900k heap when GC occurs, or more depending on how much heap you pre allocated. How does the performance difference happen? Does anyone ever have the same experience?
Q3.
My last question (sorry for asking so much:p), in order to play the same audioclip multiple times in a short period(overlapping may happen), what’s the best method performance wise? I’ve read several post about play multiple audio clip but they have different opinions. For example,
http://forum.unity3d.com/threads/17165-Playing-sound-causes-gradual-performance-loss
In this thread it’s said PlayOneShot() will cause performance issue so using multiple sound source to cycling is better. But I also read here that:
http://forum.unity3d.com/threads/39548-Number-of-audio-sources-question-(optimization)
They say using PlayClipAtPoint is “quick and efficient”.
Which one should I go for? I have some quick sound that gets played whenever there’s an input. So it can be played 5 times within a second. I want to ensure the sound will not interrupt each other and won’t have an impact on performance.
Thanks a lot for reading, any tip would be highly appreciated ![]()
nantas