Improving the Performance of a Mobile Game in Unity
Gaming on mobile has evolved quite a lot in recent years, from having simple 2D games to offering a full 3D experience. But despite that, it still has limited processing power, so to provide a smooth gaming experience, some considerations need to be made regarding design choices.
Below are the top 5 points to look at to improve performance on mobile devices when developing in Unity:
Avoid Transparency
Pixel overdraw is quite expensive and could drastically reduce the framerate on mobile devices. To prevent this, avoid using Transparent Shaders or basically any Shader that contains transparency (ex. Particle Shaders).
For Opaque geometry use Shaders from the Mobile category.
Avoid Real-Time Shadows
Real-time Shadows might look cool, but they require quite a lot of processing power. So it's best to bake them into Lightmaps instead.
Use Static Batching to Reduce Draw Calls
Static Batching is a way to let Unity combine Static Objects together, which in turn will reduce the number of Draw calls, thus improving rendering performance.
To enable static Batching mark all the static Objects in Scene as "Batching Static" then go to Edit -> Project Settings... -> Player and make sure Static Batching is checked.
Use Dynamic Batching With Caution
Dynamic batching is somewhat controversial. On one side it lets Unity combine Dynamic Objects into fewer Objects, potentially improving performance, but on the other side, it has to do so every frame which could hurt the performance instead.
Overall it's better to disable Dynamic Batching when targeting mobile platforms.
Avoid Using OnGUI
OnGUI lets you quickly create user UI from code but it's very slow compared to UI Canvas, so only use it for prototyping.