- Home /
Android optimizations - worst offenders?
I've ported my Win/Mac project to Android, and to my delight, it runs pretty much 'as-is' but it's got a terrible frame rate.
I was wondering if anyone knows which are the most important optimizations, in which order I'll get more bang for the byte, so to speak?
I've already reduced the poly count quite a lot.
I have a few textures, I try to keep them below 512x512, but is that too big? How much is too much?
I have some shaders running, specifically using Bumped Diffuse, Bumped Specular, and Reflective/Bumped Diffuse. Do these run in HW or are they emulated?
I have some scripts, they're pretty low-powered stuff. I do use the WWW object every 5 seconds to update elements in the scene, is there danger in that?
Any tips appreciated.
Is there any log that might give clues, or a profiler? What about that $$anonymous$$ono Developer?
Woot! 3.0f1: I don't know what they did, but now my app runs $$anonymous$$UCH faster. Thanks Unity!
Answer by jtbentley · Sep 13, 2010 at 11:11 PM
My guess is running through the iPhone script optimisation guide (it's in the manual) will be well worth it. Also, which phone are you running it on? There's a lot of hardware variaiton on the android platform.
Answer by Bampf · Sep 15, 2010 at 01:35 PM
When I ran my iPhone game, which has some non-trivial scripting in it, through the Unity 3 profiler, I was shocked. More than 70% of the time was spent doing GUI operations of one form or another.
If you are using UnityGUI calls or even GUITextures, you may want to look into rewriting your UI to use textures that all operate off a single material. This can reduce the drawcalls needed to 1. A product like EZGUI or the GUIManager script can help with this, though I personally have not tried either one yet.
(This is one of the topics mentioned in the optimization guide that JTBently mentions in his answer. Don't underestimate it.)
I should also mention that 5% of the time was spent in an OnGUI call that I didn't need and thought I'd removed from the scene long ago. So nothing beats putting your game through a profiler. If you are not planning to move to Unity 3 w/iPhone, you could port a version of your game from Unity 1.7 iPhone to Unity 2.6 Pro, and profile it there.
Good to know, thanks. I do have GUITextures in the form of the DualJoysticks prefab. I'll try removing them to see how much it saves. Profiler: I have all 3 versions (2.6/1.7 and 3.0b7) but I've never run the profiler, it works on phone devices too?
Yes, though keep in $$anonymous$$d it's profiling the game in the editor, not on the device. Select the menu Windows->Profiler while your app is running. I don't claim to know what everything means, but you can get some idea how much time is being spent where.
Thanks, yeah I see that most of my time is spent rendering, hardly any in scripts. But I do worry that it's not profiling the device itself. I mean, Android vs iPhone vs ATI vs Nvidia - big difference in low-level rendering power, so it's hard to tell for sure.
A valid concern. You can probably apply a (non-Unity) Android profiler to the problem if you have one, to verify what the Unity profiler is saying. On the other hand, if you see things you can eli$$anonymous$$ate like I did, the exact % may not matter. And desktops are so insanely good at rendering these days- if that's where Unity spends most of its time, then it's likely the device is the same or worse.