TexturePacker Sprite importer script

Hey everybody.

I’ve written a TexturePacker import script for use with the new Sprite system introduced in Unity 4.3.

The script is available here.

(If you’re unfamiliar with github, you can click the “Raw” button to get to the raw C# file and then save it to disk from your browser.)

Usage:

  • Add the script somewhere inside your Unity project Assets folder. (I use Assets/Scripts/Importers)
  • Export an atlas and texture from TexturePacker into your project. Use the png and generic xml formats. (Don’t check “Allow Rotation.”)
  • Profit

It looks like the SpriteRenderer references the sprites by index, so if you delete a texture from your atlas, when Unity reimports, I fill the gap with a sprite named “DELETED_SPRITE_#.” New textures are added to the empty slots first.

The script (like all of the files in my UnityTools repo) is public domain, so you’re welcome to use it however you like. If you see a way I can improve it, I’d love your feedback.

2 Likes

Very cool, thanks for sharing this! Will check it out soon.

Just tried the script, work as a charm :wink: thank you!

This is incredibly useful!

I was a bit confused how to use it at first. Here’s a step by step for dummies like me :smile:

  1. Put the PNG and XML in your project
  2. Find the PNG and open the Inspector for it (just click the PNG)
  3. Swap the ‘Texture Type’ to “Sprite” and the ‘Sprite Mode’ to “Multiple”.

Works an absolute treat, thank you ThirdPartyNinja

1 Like