
If you need to, disable the GameObject, set the position using the Transform (there's currently a bug when setting the Rigidbody2D.position while the GameObject is deactivated), then re-activate it The physics engine doesn't like and will let you know. directly setting the postion), especially if they've been marked as static.
#TEXTUREPACKER UNITY 2D FULL#
If you'd like the full story, you can find the thread here. Unity doesn't recommend using both vSync and Application.targetFrameRate at the same time though, as it could lead to CPU frame drift. Now, I'd highly recommend enforcing vSync. Basically, the framerate went from to this. However, they're two very different things, and what ended up happened was that the CPU was issuing frames faster than the GPU could handle them, as we ended up with intermittent stuttering. Because we were switching from 60fps in-game to 30fps in the menus (good for battery life), we switched off vSync and just used Application.targetFrameRate. I'd assumed that Application.targetFrameRate was the "code way" of enforcing vSync. I originally misunderstood the first two points.
#TEXTUREPACKER UNITY 2D ANDROID#
Apparently, on some Android devices, with Android 5, you can render at more than 60fps, so if you don't force vSync, you run the risk of an unresponsive device, as it's rendering too quickly, so it's possible that future versions of Unity will force this Otherwise you can turn on vSyncCount in the quality settings.Set your Application.targetFrameRate to 60.These are the simple things you need to do, and don't need much discussion. Let's get the dumb stuff out of the way first. It goes without saying that the performance issues were found using the profiler, so if you have it, it's something you should be using.Īlso, these tips are mainly focused on 2D. We don't use any lights, multiple cameras, etc.In the long term, we'd like to move to Unity JSON and the built-in compression etc in. We've since moved the compression/decompression and serialisation/deserialisation to different threads, so while there's still the issue of memory etc, there's less of an impact on the framerate. It's multiplayer, so you get CPU spikes as messages come and go.

While the levels are still built with individual tiles, we now render all the static tiles to a single RenderTexture, which sharply reduces the number of draw calls In the game scene, the world map is built with individual tiles.It uses multiple scenes, and the new Unity UI.


We're currently Android only (as it's a ton quicker to iterate and get everything working as it should), but The latest Unity version (5.3 as of - original - writing) seemed to exacerbate the performance problems on this. You see, it used to run at 60fps no problem, but as development continued and the Unity versions piled up, occasional hiccups became more and more obvious, so it was time to dig down and figure out what was going on behind the scenes. At the time of writing the update, we're using Unity 2018.2.Īt the minute I'm looking into performance with our latest game, so I figured I'd gather together all the different tips that I ended up using to get our game running back up at 60fps.
#TEXTUREPACKER UNITY 2D UPDATE#
Performance tips for Unity 2d mobile Update 09/2018: As this is one of my more popular posts, I've updated it with even more tips that I've learned in the meantime. Performance tips for Unity 2d mobile | Damian Connolly |
