Texture Packer 2D Sprites
Version 2.0 contains more advanced function for sprite render and sprite animation. Main features:
- Trim / Crop, Rotation, and Scale support
- Full Editor integration
- You can use frames for one animation from different atlases
- Animation preview in the editor
- Draw calls batching
Note: This is “on mesh” animation, it doesn't use Unity GUI system. To play the animation using Unity GUI, please read about plugin GUI classes.
You can use your or tutorial atlas to create 2D sprite animation.
Go to the
Game Object -> Create Other -> Texture Packer -> Sprite Animation
This will create new TP Sprite Animation object.
Now you can add some frame to the animation. Press Add button. Add button will call Texture Packer custom window or bring it up, if you already have it.
Note: For opening Texture Packer custom window go to the Windows-> Texture Packer.
In Texture Packer window, just select frames for your animation. You can use Ctrl/Cmd and Shift button to easily select frames you want for this animation. After frames are selected press “Add to animation” button.
Note: You can add more frames from different atlas (just switch) atlas in Texture Packer window and add another frame. And of course you can add the same frames multiple times to the animation if you want to.
That is it. That is all you have to do to set up the sprite animation from atlas.
Creating Simple Sprite
That is useful if you want atlas texture to be rendered on simple plane Mesh, or if you want trim support. Go to
Game Object -> Create Other -> Texture Packer -> Sprite Texture
And follow the same steps as form Creating Sprite Animation.
Atlas choose drop down. Use it to switch between atlases in your project.
Adds selected frames to the selected sprite animation.
Toggle between display or not display frames extension.
Search field. Start typing in this search field to filter frames result
Cancel the search. Press this button to the disabled filter and clear search field.
Info Box. It will display useful information about the animation.
Gizmos Color. Color of the box around animation.
Current Frame. Current frame of animation which is displayed in the editor. When you press play animation will start playing from this frame.
Frame Rate. Frame rate of selected animation.
Play On Start. If this option is active, animation will start playing when animation game object will receive Unity Start event.
Loop. If the options is active, animation will play a round.
Force Selection. When you selecting animation by clicking on it in the editor scene, Game object with TPSpriteAnimation component will be selected instead animation sprite. To disable this behavior uncheck this select box.
Add. Button will open Texture Packer window, or bring it up if already opened.
Clear. Clear all animation frames.
Update. Update animation view. Can be useful if something goes wrong, and view wasn’t updated automatically.
Last Optimization section was about RAM and Texture Atlases size saving. Let’s talk about CPU. One of the main features of this extension is Draw Calls saving. This is possible thanks, Unity Dynamic batching.
When you creating different animation they use the same material with make dynamic batching possible. To use it with the full power you should understand how the dynamic batching work, and render part of this extension work.
When the sprite animation is running it applying new scale and local position to the sprite every frame. It means that TP Sprite is always the non-uniform object. With means, it can be batched with other non-uniform objects, but if you will use the same material on the object with uniform scale it will cause 1 additional draw call.
Using frames for different atlas is a great feature. But you should understand that animation sprite will switch materials while playing in this case. Every additional material on scene this is additional draw call.