Sprite Animation and Sprite Packer (Sprite Atlas)

In a recent project, I'm dealing with a great amount of sprites. Eventually, the memory leakage is inevitably happened, and my app crash when loading the scene. (This project was developed to build on iPad)

All I get from XCode is "Terminated due to memory issue". So, I tried Instruments, a built-in MacOS app to profile the memory usage, but I cannot find anything awkaward mainly because it stop recording when it crashes. Also I tried Unity Profiler, a built-in Unity function monitors the resources usage of the game. Similarly, I cannot spot the error from executing on the iPad, but I found the usage of memory is tremendous while running on the Unity Editor (~4Gb). 

This pushes me to consider the performance of an game, particularly, on mobile devices. Image compression becomes inevitable, and sprite sheet is apparently not enough. The reason is that the texture compression method PVRTC/ETC1 only works with POT images (Only POT textures can be compressed to PVRTC format. ) For a POT image the size should be "power of 2". 

Fortunately, Sprite Packer in Unity packs the sprites into Sprite Atlas whcih is in POT format. Now, I will introduce my steps: 

[The procedure is mainly referenced to this video:

Unity Sprite Animation & Sprite Packer - YouTube]


FYI, My Unity version is 2017.2.0f3. 

1. [Edit] > [Project Settings] > [Editor] > [Sprite Packer] Mode: Always Enabled (Legacy Sprite Packer) 

2. Drag sprites (single frame per sprite) to the animation to make sprite animation. 

3. Select all sprites

4. Add Packing Tag to the selected sprites. 

5. Check [Override for iOS] and Choose Format: PVRTC

6. [Window] > [Sprite Packer] > [Pack] (It will pack all the selected into an atlas) 

f:id:fervor:20180803144940p:plain