I wanted a way to quickly slice up spritesheet rips for a game I am working on. Unity's built-in spritesheet editor has some fantastic tools to slice spritesheets automatically. However, at this time of writing there is no built-in way to export the sprites as individual images. This editor script is intended to bridge that gap, turning Unity into an automatic spritesheet-slicing machine.
This works as a standalone Unity project, or you may copy the Scripts
folder into an existing project.
You will get the best results if you pre-process your spritesheet by deleting any unwanted graphics along with the background color if any, and save it as an alpha-transparent PNG. This will help Unity's automatic slicing algorithm, as well as usually being what you want in order to use the sprite in a modern game engine. If you are looking for tools to help do this, I recommend Pixen (macOS), Paint.NET (free, Windows), or GIMP (free, all platforms).
Each texture you want to use should have the following import settings:
Property | Value | Explanation |
---|---|---|
Texture Type |
Sprite (2D and UI) |
This script is only designed to export sliced sprite sheets. |
Sprite Mode |
Multiple |
" |
Advanced → Read/Write Enabled |
☑️ | Required for exporter to read texture. |
Default → Max Size |
8192 (Or highest available) |
Prevents automatic downsampling of large textures. If your sheet is larger than this (8192 x 8192,) split it into smaller sheets using an image editor first. |
- Slice your spritesheets using the Sprite Editor.
- I recommend using the automatic slicing feature and then tweaking if needed.
- From the main menu bar, click
SpriteTextureSliceExporter
→Export Slices
.- I wanted this to be in the context menu as well but couldn't get it working. If you can figure this out please send a PR!
- Choose a folder to export images to.
Note: I have not tested this on atlases, only spritesheets attached to individual sprite assets as described above.