Jump to content

Spriter Data API for Unity


Recommended Posts

Spriter Unity API - NGUI and B3 compatible

Overview

After a fair bit of work I've got a version of the API that works with the latest Spriter file format and NGUI (specifically, the free version). This isn't quite final; there's still one or two minor things that aren't quite right, but I'd much appreciate any help that can be offered to sort them out.

I've also separated out most of the Library independent code. If you'd like to extend this to ex2D (for which I don't have a license) you should hopefully only have to implement the reduced amount of code in SpriterDataNGUI. This mostly deals with Atlas creation.

The plugin passes all of Timpart's Spriter Test Suite version 0.2.

Demo

NGUI/Spriter Demo

This demo shows the "Monster" example, with varying pivot points between animations and bone animation used.

To Download:

NGUI. The free/evaluation version also works great.

https://github.com/CptDefault/spriterdapi-unity/

https://github.com/CptDefault/spriterdapi-unity-ngui

Download both of the above repositories and place them into the Assets folder in your Unity project.

NGUI Free vs NGUI Full

To use the full version of NGUI, open "Spriter-NGUI\Editor\SpriterDataNGUI" and comment out line 34. Make it look like the following:

//To use the full version of NGUI, comment out the following line.
//#define NGUI_FREE

To Use:

Make sure the Spriter project you're importing is inside the Assets folder. Whilst there's nothing stopping you selecting another directory it's likely to break the plugin.

Unity should now have a "Spriter" menu option, to the left of "Window" and "Help". In here you will find "[NGUI]Create New Character".

This will create the character using Unity's legacy animation system. From here there is no reliance on any of the scripts in this project beyond the colour helper.

Future Goals:

  • [*:17vpbp7y]Automating the import process when the .scml file is updated.
    [*:17vpbp7y]Extending the project to work with 2DToolkit and/or ex2D.
    [*:17vpbp7y]Adding a (non-recommended) mode of operation with no toolkits

Known issues:

  • [*:17vpbp7y]Sprites are sometimes a few pixels off from where they should be. I'm investigating this but haven't found the cause.
    [*:17vpbp7y]Opening the example scene might cause sprites to flicker when they change. Re-importing solves this.
    [*:17vpbp7y]Half the commit messages were written with "R3" compatibility. I meant "B3". Whoops.

I'll likely have to take a week off from this to catch up on my other projects; but rest assured I will be continuing support for this. I'm looking to use Spriter for a major games project this semester.

If you run into any trouble at all, post it here and I'll do what I can to help find a solution.

Lastly, I'd like to thank Thinksquirrel for the great work getting this project started.

Cheers,

CptDefault

Link to comment
Share on other sites

  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

Apologies, I neglected to test the plugin with 3.5.

You've taken the correct steps in deleting the Example/Imported folder. You'll most likely want to delete the Example/Scene folder as well.

The last step you'll want to take is to make sure the Spriter project you're importing is inside the Assets folder. Whilst there's nothing stopping you selecting another directory it's likely to break the plugin.

I'm running Unity 3.5.7 (for this test, usually I use 4.x) and Win7 so I shouldn't imagine there'd be too much difference between our setups. Have you got an up to date version of NGUI? The latest version seems to be found at http://www.tasharen.com/?page_id=140 under the heading "Evaluation Version".

In regards to using this without other plugins; it should be possible. Don't expect the full ease of use or efficiency of those other plugins, but it's definitely doable.

I might look into doing so once I've got some other projects back on track. Expect such a thing in two or three weeks.

Spriter works on PC, Mac and (I believe) Linux. This plugin should work on all platforms supported by Unity, but I haven't tested on any other than Windows standalone and the Web Player.

Thanks,

CptDefault

Link to comment
Share on other sites

Seems odd. Perhaps the free version of NGUI is different in some slightly odd manner compared to the full version.

Could you load up those script files and try replacing all references to UIBaseAtlas with UIAtlas? It's possible that might help.

The two errors regarding SpriterNGUIColorHelper are due to slightly flawed design on my part (I'll fix it in the next update) and as you've noticed are fixed by importing the second module.

Let me know how that goes.

Thanks,

CptDefault

Link to comment
Share on other sites

Hi Michael,

Unfortunately the examples folder simply doesn't work with 3.5. Next time I get a chance to do a revision I'll build it from 3.5 instead.

It's odd to hear that there's issues with the full version of NGUI. I'll see if I can get hold of an updated version myself and sort it out, but I'm not sure how soon I'll be able to do that.

I'm vaguely aware of a bug where things aren't quite where they should be but the animation I've been testing with is much less pronounced than that. Is there any chance you could send me a copy of that animation purely for testing this? My email is my username at gmail dot com.

Sorry to hear that you had trouble finding the import option. I'm hoping to streamline that in the future.

Thanks,

CptDefault

Link to comment
Share on other sites

Thanks for the file, that's helped find the issue.

The git has been updated and should now be fully compatible with Unity 3.5.

Regarding full NGUI compatibility; would you be able to send me a screenshot or log of all the errors you encountered? If we're lucky it might be a simple enough fix once I know what's going on.

Let me know if you have any more trouble.

Thanks,

CptDefault

Link to comment
Share on other sites

Thanks for finding that!

I've fixed up the version on the repository. To use the full version of NGUI just comment out line 34 in SpriterDataNGUI, which looks like

#define NGUI_FREE

Hopefully things work from here. As always, let me know if you run into trouble.

Thanks,

CptDefault

Link to comment
Share on other sites

@CptDefault:

Just wanted to say, awesome job for continuing this! I've been pretty busy and hadn't been able to get back into Spriter...glad to see someone be able to take the project and run with it. I've updated the links on the main page to your fork for now - I'll take a look and update the main repository as well.

Glad to see the main library cleaned up a bit also. I'm thinking we could reach out to some developers that may be interested in getting Spriter to work with their tools. 2D Toolkit comes to mind - they have a robust editor API that can be taken advantage of.

Link to comment
Share on other sites

  • 1 month later...

2D Toolkit is being worked on. It's by far my favourite toolkit to work with, and I should be able to have a basic version up pretty soon if there's demand for it.

Currently I'm working to add auto importing when you update a .scml file, but that's leading to a bit of instability so I'd rather not release that.

I'll see if I can get a basic version of 2D Toolkit support (same level as NGUI) up this weekend.

Thanks,

CptDefault

Link to comment
Share on other sites

  • 2 weeks later...

Hi!

Me and a couple of friends of mine are starting a plattform game in 2D. We are gonna use Unity 3D with Orthello framework. I read in the first page of this topic that someone has imported the animations of Spriter into Unity and works with Orthello. My question is if it's feasible and relatively easy to import this animations into Othello.

Thanks a lot!

Link to comment
Share on other sites

I don't believe the current version works with Orthello. That said, depending on how good the editor integration for Orthello is, you might be able to get it up and running without too much work. Look at the current implementations for an example of how to integrate it.

I'm still hoping to have a 2dTK version up soon-ish. Unfortunately I've got rather a lot of work at the moment, so I haven't had a chance to polish out the bugs.

Link to comment
Share on other sites

  • 1 month later...

This plugin is coming along really well. It was super simple to test out.

I'm noticing definite problems with the art packs just released. For the 'player' in the Basic Platformer Pack, one of the arms seems malformed, and the animations I tested (walk and idle) both do funny things with the other arm. Those are the most major issues I've noticed - hopefully minor fixes, though they're problematic enough to prevent using this plug-in right now.

Some other notes:

* It's non-ideal to create a bunch of animations and dump them in the root Assets directory regardless of where the Spriter project was placed. It's an organizational headache. Would be much nicer if the animations were placed in a subfolder with the same root as the Spriter project.

* A non-NGUI version would be nice. I'm not sold on my UI solution, and the NGUI free version plasters a big watermark over my game, so obviously it can't live side-by-side with whatever I do land on. A version which just uses textured quads would be sufficient. I can probably roll my own variant on that at some point, though.

Good job so far!

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