Skip to main content

Performance Optimising tips for Unity Mobile platforms

If you're using Unity3D for your mobile games whether it's 2D or  3D game, you will need to optimise both your codes and GPU usage to get your game smoothly running in mobile platforms.

1. Always use the Performance Profiler


  • Set the build to development mode and keep connecting the USB to the computer while running the game on the device


2. Use static batching if you're using Unity Pro


3. Use dynamic batching for the objects that're always moving


4. Optimise the physics usage


  • Use Built-in Physics
  • Use 1/1 Scale all the time
  • Don't use mesh colliders
  • Set the Mass the right one
  • Use the fixed timestep (0.03-0.05) 
    • Edit->Project Settings->Time
  • Use TimeScale scaling

5. Sprites and Texture optimisation

  • Lower the fillrates - (Trim the textures that has alpha transparancy)
  • Hide the sprites that're not using (Offscreen)
  • Use Dynamic batching by using texture atlases
  • resize the sprite's quad not the gameobject's transform
  • Use the spritesheets
  • Use the right shaders
  • Give it a right compression (PVRTC for iOS and ETC for android)
  • Turn off mipmaps

6. Using Pooling objects

  • Instantiate once and re-use when needed
  • Instantiate the minimum amount of game objects at the game start

7. Optimising Sounds

  • Set Background music to "Decompress on Load".
  • Compressed on memory for short clips
  • Force to Mono (Edit->Project Settings->Audio)

8. Optimising UI and HUDs

  • Old Unity GUI system is slow and avoid using it for mobile.
  • OnGUI function is slow and avoid using it on game.
  • Use third-party UI system such as 2D toolkit and Sprite Manager for UIs.
  • Keep all the UI animations on FixedTimeStep() function.

9. Build Options Optimising

  • Disable accelerometer if not needed
  • Strip things down (use .Net subset and micro mscrolib levels)

10. Misc

  • Use Resources.Load() at the game start and never use it again.
  • Avoid using GameObject.Find() and GetCompoenent() functions at the run-time.
  • Avoid using reflective functions.
  • Using too much memory can also slowdown the game.
  • Avoid using garbage collectors as they're very slow.
  • Keep using FixedUpdate() or FixedTimeStep() function for all your gameplay if possible.



Comments

Popular posts from this blog

Using XAML on Monogame for WinRT (Part 2)

Integrating Monogame with XAML Metro UI If you're coming from the previous section, you now have a metro UI application project with blank page and also have monogame.windows8 library reference to the project. Now Let's fix some source code for the  pages to get XAML working with monogame. Step01 ( Hacking App.xaml.cs file) App.xaml.cs delivers the most important start point while rendering a particular page in Metro UI application. I added gamePage and mainPage as  a public variables as they become accessible from other classes to for page nagivations. Here is the source code for to see what it looks like for the final App.xaml.cs file. sealed partial class App : Application     {         public ContentManager Content { get; set; }         public GameServiceContainer Services { get; set; }         public GamePage gamePage;         public MainPage mainPage;   ...

Getting Started with Monogame for WinRT

Monogame is the opensource XNA development framework where the XNA developers for XBox, Windows and WP7 can be able to port their games for iOS, Android, Mac OSX, Linux, Windows 8 Metro Style apps and PlayStation Mobiles. As XNA framework is not allowed to create Windows 8 Metro App anymore,  Monogame becomes the best framework to port the current games written in XNA. Monogame framework rewrite the XNA wrappers using SharpDX which is the current fastest Direct X Wrapper for C#. Although there are opensource game development frameworks for WinRT is available, Monogame is the one that shouldn't miss if you're a former XNA developer or C# programmer. You will need the following software and tools if you're really new to WinRT development environments. Windows 8 Release Preview   Visual Studio 2012 Release Candidate   They're currently in beta, so you can go unlimited trials for these until the final releases comes out. If you're not planning to...

Optimising Unity new UI System

UI/Sprite textures aren't packed into a texture atlas by default. A tag is needed to group them. Read the documentation / tutorial on the sprite packer. Overlapping text/graphic boundaries with another text/graphic will create additional draw calls, even if the actual visual graphics do not overlap. Grids (other layouts too I presume) need minimum 1 pixel spacing between items, else items are considered overlapping and will create additional draw calls. Images with alpha 0 are still rendered. They are rendered with alpha 0 even though they are not seen. Unity currently does not support non-rectangle shapes as Sprites, so using the TightSpitePacker policy will cause image artifacts. When UI objects are offscreen, they are still batched (rendered as well?). Possible solutions: Change parent to non-UI parent, as UI Camera will no longer detect it Change layer of panel so UI Camera will no longer detect it Disable gameobject when off-screen ScrollRect performance tuning S...