- Home /
What can I do to further optimize mobile game? (2D)
Hello,
I'm creating a pretty simplistic puzzle game with lots of boxes the player can move around. Complexity of the scene should be somewhere around bejeweled. However I'm getting really atrocious performance on mobile devices, here's stats.
Android Unity internal profiler stats: cpu-player> min: 64.6 max: 90.1 avg: 71.3 cpu-ogles-drv> min: 0.5 max: 3.2 avg: 1.2 cpu-present> min: 0.0 max: 0.5 avg: 0.1 frametime> min: 65.7 max: 91.0 avg: 72.5 draw-call #> min: 34 max: 34 avg: 34 | batched: 75 tris #> min: 186 max: 186 avg: 186 | batched: 150 verts #> min: 372 max: 372 avg: 372 | batched: 300
player-detail> physx: 0.5 animation: 0.0 culling 0.0 skinning: 0.0 batching: 29.8 render: 35.5 fixed-update-count: 3 .. 5
mono-scripts> update: 0.1 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 385024 allocated heap: 643072 max number of collections: 1 collection total duration: 6.2
The statistics window in unity shows ~33 drawcalls, ~60 saved by batching, 144 tris, 288 verts.
Majority of the stuff (the boxes) is contained in a single spritesheet, sprite mode Multiple, it has a packing tag, max size 1024.
I have enabled Dynamic batching, Multithreaded rendering (no crashes yet at least) from the build options and Sprite Packer is set to Always Enabled in the Editor Settings. However none of these seemed to affect my performance much.
Each object I draw is a separate gameobject with spriterenderer, they share the Sprites-Default material however. The scenes have 60-100 of these gameobjects (if this is the culprit, is there a better way?)
By my understanding all my sprites should be rendered with minimum drawcalls and overhead. If anyone knows what I'm doing wrong I'd be thankful.
$$anonymous$$aybe I'm being blind but point out the really atrocious bit.
Frametime being ~71 when nothing is happening and often climbing to around 100 means about 10 fps. Touchscreen really does not feel responsive and the game is very jerky.
I'm trying to figure out why your CPU usage is so high with only 34 draw calls... It says your scripts are very fast... 0.1 in update is almost nothing...
Looks like batching is whats taking up the most time on the CPU.
Interesting, your game appears to be CPU bound, but the internal profiler isn't giving enough information to account for the extremely high frametime. Since batching apparently isn't the problem, perhaps it would make sense to use another profiling tool.
I'm sure there are tools similar to xCode's instruments available for android.