I’ve been making games in Unity for the OUYA intermittently for a couple years now and I’ve learned a few tricks to getting games to run and look better on the OUYA and Android in general. I am in no way a professional or expert, so I won’t be able to say why something is in most cases. I also apologize if these are obvious but hopefully some people will find this at least a little helpful. Here are the things I’ve learned:
- Set application.targetFrameRate to 60. This is for Android in general especially on older devices. This is set to 30 by default for some reason.
- Set the resolution to 720p for older devices. This is mostly for the OUYA since, unfortunately, it is an older device with not a lot of ram. This can be set with Screen.SetResolution in Unity. Also, well optimized games can use the 1366 X 768 resolution without losing too much performance on the OUYA
- Avoid shaders if at all possible! This is mostly for the OUYA. I’ve noticed that when using shaders the performance drastically goes down, although I believe it is possible to get around this if you understand how to make lightweight shaders (which I do not)
- Use Mobile materials in Unity for mobile. This is for low end Android devices including the OUYA. You’d be suprised how much performance this can give you. For my Christmas Defense game I got a 15 - 20fps boost by doing this.
- Watch your poly/vertices count! This is for low end Android devices including the OUYA. I saw somewhere that a good poly count is anywhere from 300 - 1500, but I can’t remember where this was so please take that number with a grain of salt. One easy way to do this is Mesh Simplify | Modeling | Unity Asset Store , I am using this on my OUYA game 3D Christmas Defense and it does wonders
- Use cubes instead of Planes in 3D games. This is for low end Android devices including the OUYA. I noticed that when using the Mesh Simplify script that Planes has a little more than 100 vertices while a cube has around 24! That can make a huge difference especially when you need a lot of them!
- Override your sample rates for audio clips and set them to at most 22,050. This is for low end Android devices including the OUYA. This can slow down the device and I definitely noticed the performance hit in my OUYA game 3D Christmas Defense when I tried a higher sample rate.
- Use Android Native Audio for playing sounds with very low latency. Link: Android Native Audio | Audio | Unity Asset Store , this is pretty easy to use and I noticed a huge latency improvement when using this instead of audioSource.Play().
- Use an Object Pooler! This is for Android in general. When using guns and multiple projectiles, instantiating and destroy creates a lot of garbage for the Garbage Collector which can cause huge lag spikes especially on low end Android devices and the OUYA. Even using it for enemies in wave defense games can help immensely.
- Disable lightmaps and shadows. This is for low end Android devices and the OUYA. These kinds of calculations can really slow down older devices. You might be able to get around this with light baking, but I don’t know to much about it to say anything.
- Get rid of null/unnecessary checks when possible. This is for low end Android devices and the OUYA. When you have null checks in Update functions, that means that the one check is called 60 times and from the way Unity does this can cause a slight slowdown.
- If your sprites are looking choppier/different from your sprites, change your sprite import settings to not use compression and change the max size to something higher. The max size part may not necessarily work but the compression part most likely will.
- When having a camera following an object moved by rigidbodies, use FixedUpdate() to move the camera. Rigidbodies use Unity physics engine which is updated separately at 50 fps (which I believe can be changed in settings) and FixedUpdate is ran in sync with the physics engine. This info may be wrong so please take this with a grain of salt.
- Set objects to static if they don’t move at all within the scene. This is for low end Android devices and the OUYA. If the object is set to static, Unity knows that it can calculate information on it at the beginning and then forget about it, allowing Unity to use that calculating power on other objects.
- Decide on the pixels per unit size for sprites in Unity. This isn’t big, but can help prevent burnout or stress later on if you need to change it later.
- Disable unnecessary checks in the Layer Collision Matrix in the Physics section. For every collision check the system doesn’t have to make, the better.
- Awake() happens before Start(). Not a biggie but if you have Global Instances, they should be set in Awake and accessed in Start if necessary.
That’s all I can think of at this moment. Again, I am no professional or expert, so this info may be incorrect in some situations. This info is simply based off of my experiences with Unity on the OUYA. Please feel free to correct me in the comments below if some of the info is off. Happy Programming!