Jump to content

Spriter Data API for Unity


Recommended Posts

I got Spriter working using the free version of NGUI and the APIs in this forum:

However, I just bought the full version of NGUI and now it doesn't work. I updated to v3.0.4 and still no luck. I commented out the #define NGUI_FREE like I was told in the instructions.

I get several errors (No overload function for method 'ImportTexture' takes '3' arguments) which can be fixed by adding a 4th boolean value to the calls.

But I can't seem to fix the other error (Can not implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.List' for the line 345:

List spriteList = atlas.spriteList; in SpriterDataNGUI.cs

Are the APIs not compatible with the new version of NGUI?

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

I've been digging around the code a bit, and I managed to get the basic 'idle' animation in the basic platformer kit to look completely normal by changing a line in SpriterDataUnity.cs, line 422:

colorHelper.transform.localPosition = new Vector2(-pivot.x*sprObj.targetFile.width,

(1 - pivot.y)*sprObj.targetFile.height);

Previously, you were adding a padding vector in there. I'm not entirely sure what that's intended to do (I'm not up-to-date on my SCML format knowledge), but it seems to throw the whole image off. Removing the padding addition gets the rendering to behave normally.

Note, however, this doesn't address some animations jerks that are showing up with many of the animations (balance_check is the worst).

Edit: After more fiddling, I managed to get the animations to look correct. In SpriterDataUnity.cs, line 438-ish where targetRot is initially set, I removed all that funny math and just used obj1.angle. I did the same thing for the nearby calculations. This appears to clean up most of the animations.

My changes are probably not accurate (I was just hacking), but it might give you a jumping-off point.

There are still subtler bugs: the balance_check has a hiccup when it loops, and the stand_up seems to switch images erroneously at the end.

Link to comment
Share on other sites

  • 2 weeks later...

Hello there

i've got something new and different, just for Unity 4.3

https://github.com/Malhavok/Spriter2Unity

It's a tool, written in python, that converts your SCML files into Unity prefab's and anim's.

For every entity in the file a prefab is created and for every animation in the file, anim is created. All created files are native to the Unity and can be used like any other Unity resource (you can instantiate these prefabs and add events to animations and use animations in state machines)

The main limitation is that you have to assign all the sprites in Unity again, that is images to proper nodes. Each node is named after the file it should contain, so it's not that hard, but takes time.

When importing sprites into Unity, you should leave them with pivot in center (the default option), as this tool takes care of proper positioning of everything.

It was tested with the sample project hosted on the site and it contains it's own simple project. Seems to work well with boned meshes. Currently it seems not to work with things like pickups, that is a things with only sprites, but that should change when i'll get some more time.

You're welcome to test it and point bugs / missing features (like alpha for sprites, that i'm aware of) and use it however you want (except for selling it, be a nice person)

Link to comment
Share on other sites

  • 4 months later...
Have you seen this resource for detailed explaination of the data format? Edgar should be updating it fairly soon to cover the new features.

http://www.brashmonkey.com/ScmlDocs/ScmlReference.html

Is that supposed to be a serious piece of documentation? Because there are quite a lot of errors in that document - considering its pseudocode.

There are a lot of references to variables that don't exist, so to try to implement something from scratch using that document leaves you guessing at what have the code should be doing.

Link to comment
Share on other sites

  • 4 weeks later...

Hello,

I am making a game and i have a problem in a specific animation,

The problem is at the left hand the one behind the body.

i am attaching two videos one is how looks in Spriter and the other one is how the same looks at unity,

Why it behave like that? it has to do that a rotation is involved on Spriter or is on the API side?

Spriter:

http://youtu.be/dzvBafdVK0I

Unity:

https://www.youtube.com/watch?v=65AwCRC ... e=youtu.be

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.

Guest
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...