Performance problems on Android (apk)


I’m having really bad performance problems on Android and I don’t know why. Everything runs smooth on my crappy PC with Windows XP (compile as exe) but I get serious lags and hiccups on Android even with version 4.1

The game is in 2D.

Here is what my game does and have:

  • A camera with an Autoscroll script between 2 and 3 units per second on LateUpdate via GameObject.transform (velocity,CoRoutine,InvokeRepeating,Update,FixedUpdate has caused lags and hiccups)
  • 3 non-moving ObjectPools which contains 500 total childs. Each GameObject only has a 1x1 BoxCollider2D and a disabled child and if the camera hits the collider the child gets enabled and if it leaves the camera the child gets disabled
  • on average 15-20 moving Objects on LateUpdate via GameObject.transform
  • 6 moving background sprites which moves with velocity and they are attached to the camera
  • A player which moves with velocity and is attached to the camera
  • 4 running CoRoutines each with 0.1-0.4s sleep which place the Objects from the ObjectPool and do other stuff like score

If I increase the moving Objects on the camera to 30 I get lags from time to time and If I increase it to 40 it’s unplayable.

Any kind of advice or tip is appreciated.

PS: I don’t own Android Pro and Unity Pro.

Go to player settings → Android settings → Other settings → Unmark Auto graphics API and delete OpenGLES 3 from the list.

It should solve your problem.