Optimization: Tags

This article cover my experience with Unity Packaging Tags and a Game breaking error caused by the sprite packer.

I have been told many times packaging tags help in performance. They are suppose to mash textures on one big texture sheet defined by the Packaging Tag. These texture are then loaded once hopefully during a scene load and then don’t need to be loaded unloaded thereafter, saving some memory calculations.

Honestly I will add the tags, but I have never seen a direct change in fps because of this. In my current game I added the tags based on the scenes. I saw an interesting GDC talk and read an article on Gamasutra. It said,

If these big atlases are divided based on Transparent, Semi and Opaque textures.

This leads to some amazing performance gains. I say, I am positive that one day I’ll see those gains too ðŸ™‚

Sprite Packer packs based on the its packing policy and Packing Tag

A Game breaking error…

This one time a game’s build was crashing because of the sprite packer. The error said the Sprite Packer failed due to memory issues. Turns out, there is a maximum limit of memory the Sprite Packer can handle. The build would max out on the system’s memory while packing all the tagged sprites in the game. This was happening because,

Unity packs all the sprites in the Sprite Packer in one single pass.

If this exceeds your system’s memory limit, your build will fail.

For the solution, we first tried different packing policy in the Sprite Packer. We tried the Tight Packer Policy to reduce the number of pages the Packer produced. This didn’t help…

Then we divided the pages and tags into smaller groups. This didn’t help…

So, with all our attempts were in vain. We tried something else. What finally worked was to

Force Unity to build the Sprite Atlases in multiple passes.

These multiple passes were defined by groups. This finally led to a successful build while still maintaining all our sprite atlases.


Here’s a link to the issue reported by others.
https://forum.unity.com/threads/sprite-packer-runs-out-of-memory.229999/


Also, something similar was reported to Unity’s Issue Tracker. Here’s the link…
https://issuetracker.unity3d.com/issues/during-sprite-atlas-packing-unity-editor-crashes?_ga=2.211928849.440150030.1585935700-219971247.1575100494

Maybe it will be fixed one day, maybe by the time you read this …maybe.