Jump to content

Spriter for Unity 4.3


Recommended Posts

Hi there

I like both Spriter and Unity so i thought that i'd be lovely to use them together. When Unity 4.3 came out, with 2d support and stuff, this was the first idea that came to my mind. So, after spending some time after work, i present to you - Spriter2Unity

Currently it's very rough, could call it "pre-alpha" state.

What it does:

- converts scml file into Unity prefab and animation

What it doesn't:

- assign files directly to Unity SpriteRenderers (you have to do it by hand in the editor :/)

Why so:

- you get the most Unity-way objects, that is prefabs, so you can use them Unity-way

- you get the most Unity-way animations, that is anim files, so you can use Animator Controllers and State Machines and all magic connected to it

here is the link:


(the code inside is kinda hacked together, so be warned if you stray into it)

i've tested it so far on the GrayMan free asset and on an asset connected to the repo - seems to work fine. If you notice anything wrong, leave an issue or a post, describing what's wrong (scml files that cause problems would be cool)

it seems that it doesn't work for boneless animations, i'll be looking into it.

Link to comment
Share on other sites


this is the proper topic about implementation of spriter2unity converter.

post your answers here, please

eo oot

there is a known bug with exporting "just sprites", i have some troubles finding it (and a little time to do so), so if any1 finds anything, a message would be nice (either on github or here). the bug makes exported animations unusable, as everything goes "loco". but with some simple, skeletal animations everything seems fine

Link to comment
Share on other sites

hi there

a major update for Spriter2Unity came today and it features:

- automagical sprite assignment

- gui tool for windows users

- fixed multiple bugs with z-sorting

- it seems that everything from b5 is supported, but NOTHING from b6 (yet!)

and it can now:

- create native unity prefabs that match spriter entities

- create native unity animations that match spriter animations

so it's, like, fully functional now. there are probably some missing features (like it's impossible to retarget animation currently).

Rather simple "how-to" to make it work:

https://github.com/Malhavok/Spriter2Uni ... ke-it-work

If you got any questions, drop them here and i'll try to update wiki.

If you find any bugs, post them via github bug tracker or here.

Have fun!

Link to comment
Share on other sites

what do you understand by skinning?

If it's replacing a single texture in all frames of animation, sadly it isn't yet v.v There are multiple problems with that and i'm still thinking about it (mainly, the way unity handles files, the way the transitions work etc etc). However, when that problem is solved, character maps shouldn't be far behind.

Link to comment
Share on other sites

  • 2 weeks later...

Hello! Great effort, but I of course have bugs to report :P


* The prefab is rotated 180 degrees, so the character is on his head when put into the scene.

* There's a Z-sort bug where his hat is placed behind his head.

* His feet have changed places! It seems like the images linked to the bones have simply swapped places.

I followed Edgar's video tutorial, and Spriter2Unity didn't report any metafiles missing. Tried redoing all the steps, but the same thing happened.

I can send you the Spriter-project if that would be helpful for debugging purposes :)

Link to comment
Share on other sites

Hi there!


Would you be so kind and do the following steps:

- try to download the latest version from the github

- if everything still ain't working as it should, would you mind sending me the problematic scml along with some placeholder graphics at malhavok (at) wow (dot) com, so i could check exactly what kind of problem is there and perform a fix for it.

oh, and if it was made with Spriter b6.1, i've just started working on support for that so some things may still be "plain wrong", but still - sending me the project will probably help me find and solve problems faster.


character maps are here! after some research (and some hacky code) i managed to allow dynamic animation retargeting. It's still fresh but should be good enough for starters. Be sure to read the notice on the github page before diving in!

an example (thank to Edgar and Michael for help):

https://dl.dropboxusercontent.com/u/588 ... ps_osx.zip

https://dl.dropboxusercontent.com/u/588 ... ps_win.zip

Link to comment
Share on other sites

Hey everyone,

Is anyone getting an error in the generated prefabs about a "missing script"? I get an empty/broken behavior on any prefab I generate using Spriter2Unity. It appears to be missing out on the script that I copy over from the "Unity Assets" in the Spriter2Unity tool folder (S2U_AssignSprite.js, I think?). This prevents Unity from actually displaying any textures at all when I drag the prefab into a scene.

Some information:

OS: Windows 8.1

Unity version: 4.3.3 Pro

Python: 2.7.6

SCML file: Crabby (from the Spriter2Unity examples)

I have visible meta files turned on, point to the right python/scml file/textures folder, then the tool creates all the anim files and prefab. I then copy over the contents of the "Unity Assets" folder into my Assets (so I end up with /Assets/Spriter2Unity with just one .js file in the /Workers subfolder.) Then I copy over the anims and prefab into my assets folder.

Should I be seeing more files than just the one .js file in my UnityAssets?

Is there any other SDK that I need to have installed (JDK, for instance)?

Thanks in advance if you can help. If nobody has any ideas, I'll debug it tonight after work.

Link to comment
Share on other sites

oh my, i've received a mail notification only for the last one... so sorry for the late response!


- you can't change the material during conversion process :/ didn't think about it (yet)

- i'm developing it on mac, so it works on mac. however there is no GUI, you have to use terminal. just go to Spriter2Unity project directory and call "python convert.py [scml file] [unity directory with meta files and content]

- i'll try to prepare a video for it (or even better - i'll try to convince my gf to write a new GUI, this time in java or something portable)


- file structure should be: "[GAME]/Assets/Spriter2Unity/Workers/S2U_AssignSprite.js", no more scripts are currently there (it's for later, when hit boxes and spawn points will be added)

- when there are no textures when you drag prefab to the scene, it's something else - sprites are assigned to the sprite renderers during generation

- check the following, please:

* in GUI tool, whether it says that all required images are found?

* check content of the "[GAME]/Assets/Spriter2Unity/Workers/S2U_AssignSprite.js.metafile" (and send it to me. i made a big assumption about it, that i've tested on win7 and osx, but never on win8 :/)

* copy the content of the "Unity Assets" before doing any conversion

- just to clarify - no other sdk are required (the GUI is .net and it's only calling the python scripts underneath)

@ mythgarr

- check the "Experimental" directory in the Spriter2Unity

- the code that you see there is a test exporter that is creating prefab and (broken) animations. i've abandoned it as Unity editor / importing interface ain't prepared for something like spriter :/

- if you manage to make an AnimationClip instance, from code, that can be used with Animator Controller (missing muscle / animation type error) i'll just push it further. this is the barrier that i've encountered during the process

- let me know if you find something!

btw - it's better to post everything (requests / questions) on github page (as i'm getting notifications from there instantly). for reasons unknown i've received only 1 notification for the past 4 posts and i feel bad about responding to them so late T_T

Link to comment
Share on other sites


I'm not quite sure how to contact you through github - sorry! Should I just post/edit the wiki?

I've got a C# model fully rigged (The existing ones seemed potentially dated and/or supported only limited functionality). Yes - I have generated AnimationClips through code before - I actually expect that part to be fairly simple. In fact, it looks like you might be making things much more difficult than they need to be in a few places.

I'm sure I'll have more questions as I continue to work on this, but it looks like you skip the first frame of the first animation. Is there a reason for this?

I'll work on this tomorrow - I'm optimistic about having something functional sometime over the weekend. If anybody has some complex Spriter files that do weird/unusual things I would appreciate having them to test with. I haven't been able to find any reliable list of which SCML features are implemented in the current version or what changes have been made to the XML, so it will be interesting to see where my code breaks ;)

Thanks for your work - while I've still had to do an awful lot on my own (Python is not one of my native languages) it has proven to be invaluable as a resource.

Link to comment
Share on other sites


either editing a wiki or opening a new issue is fine. i'll try to help if you'll need it. also, if you'll have something nice and working i'll just give you access to the repository and i'll just scrap the python version. native is always better.

i'm missing a first frame in the first animation O.O? in python or in unity? if it's in unity, it's probably just my terrible mistake, if it's in python i'll look into it right away.

i've resigned for the native unity version for now because i had problems with generating a properly working AnimationClip :/ maybe you'll have more luck with it ^^

also, if you want i can explain "in depth" how and why i'm using animation events to change the images

Link to comment
Share on other sites


Sorry - I somehow overlooked one line of code in python. You export the first frame before going into the loop (PrefabMaker.py, make_prefab()) then skip it within the loop. I missed the separate export of frame 0,0. I'll be in touch on the github page with any more questions.

Link to comment
Share on other sites

Hey Malhavok

I have a quick question, but first I want to say thankyou for taking the time to develop a Spriter to Unity plugin, its going to be a godsend to so many of us.

The question

How much control do I have over the bones in engine, what I'd really like to do is use the Inverse Kinematics to say, place a characters legs correctly on different terrains, with something like steps I'd be able to create an additional animation, however with terrain the angles are always going to be different, so being able to adjust the legs during runtime according to slope angle would have a lot less overhead than constantly detecting if I should be playing a different animation. Is this at all possible currently, and if not, something you plan to add in future at all?

I saw on the website features 'retargatable animations', however I'm unsure if this falls under that category.

Link to comment
Share on other sites


Whoa, i never thought about it. I assume that animation going from spriter is final and definite, so i dont even plan anything like that :/ Also, it would require to implement the IK on my side as well as attaching colliders to almost everything :/

Retargetable animation means that you can take, say, a knight and replace each piece of his armor (that is sprites that are making his armor) without any changes to the animations (and during the animation).

Link to comment
Share on other sites


IK would be very cool and incredibly useful in many cases - notably, if you want to aim a weapon you could IK the arm. I haven't looked into what this would take but I'm very open to the idea once I get the base native Unity plugin functional.

As I mentioned I'm looking for some tricky spriter files that have less-frequently-used functionality in order to test the importer.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...