If you develop games with Unity and make pixel art for them with Aseprite you probably did the same annoying thing over and over again, just like me:
- Create pixel art in Aseprite
- Export the image to a png/pngs
- Open up Unity to import them, set up animations or load them into sprites
- Realize you need to adjust pixel art images
- Change them up in Aseprite
- Export them again
- Open up Unity, but realize that you have to re-do the animation, because you added one more frame now, or see that the reference to the sprite has been broken up
- Fix that
But a lot of this can be cut down to this:
- Create pixel art in Aseprite, inside the Assets folder
- Save the file and have Unity load sprites and animations automatically every time you change it
- ..that’s it
And this all can happen with the magic of the new Unity’s Scripted Importers API. (Which is still experimental by the way, but it gets the job done)
So, anyway, let’s see how setting up a project using a custom Scripted Importer for Aseprite looks like.
Creating the Aseprite file
Our first job of course is to create the pixel art in Aseprite.
We have our green guy here, with three animations: Running, Jump Charging, and Jumping. Nothing special for now, let’s save that file to Unity and see what happens.
Importing the Aseprite file in Unity
The player asset you see highlighted there is the .ase file that we saved earlier. When expanded, you can see that all of our frames are automatically exported from Aseprite and imported into Unity. And, which is more, you have the animations on the top there, ready to be plugged in in your Animation controller. And all I did was save the Aseprite file to the Assets folder.
Let’s add an animation to an object, so we can see it in action.
Automatically importing changes
Let’s say that we now want to change up the pixel art, for example – let’s make it purple.
We hop over to Aseprite and adjust the hue a bit and we have this:
Now, if we go back to unity (I’m still in Play mode by the way), we see that it is automatically re-imported with the updated pixel art, without doing anything
Auto Importer for Aseprite
I’ve bundled up the Scripted Importer that you see in action and I made an asset on the asset store, so that not only I can benefit from it.
You can find it here:
With the only difference being that the PRO version supports animations and the lite doesn’t.
Hopefully they can be of use to you too!