Jump to content

SpriterDotNet.Unity


loodakrawa

Recommended Posts

11 hours ago, Dengar said:

So this seems to have gone by me completely unnoticed. How does this tool compare to my Spriter2Unity?

It doesn't use MecAnim? I wonder if this is preferable over Spriter2Unity or whether the two tools are so different that different people might prefer one over the other.

Does it suffer from any of the stupid bugs and issues that Spriter2Unity suffers from?

Hi.

In short, the goal of SpriterDotNet is to calculate all transforms in a framework independent way and then just map the transforms to sprites in a concrete framework. Presently, it supports all Spriter features and has no unresolved bugs. Also, it is officially supported by Brashmonkey.

It doesn't use Mecanim because AFAIK that makes it impossible to use certain Spriter features (different curves, etc). The downside is not having support for the graphic animation state management tools, IK, etc. On the other hand, it offers full control at all times (e.g. modify the animation at runtime).

I guess the library choice really boils down to whether you need Mecanim support or not.

If you have any more questions, feel free to ask here or PM me.

Cheers

Link to comment
Share on other sites

I personally love the fact that both options exist.  The strength of Spriter2Unity is it actually converts to native Unity animations, so all prior animation control knowledge, existing tutorials etc. apply as soon as the animations are imported... the cost is simply lack of support for non-native like animation features.

The strength of SpriterDotNet for Unity is it offers full feature support, but is a new non, native format that needs to be learned and interacted with/controlled a new way.

I could easily see using both in the same project for different things.

cheers.

-Mike at BrashMonkey

Link to comment
Share on other sites

  • 4 weeks later...

I did a quick test with 30 chars, non-moving, animating, it seemed to be alright, but i'd have to check on mobile to be sure.
I noticed that in your main script "SpriterDotNetBehaviour.cs" you use Update. As per :http://blogs.unity3d.com/2015/12/23/1k-update-calls/
I did a few tests on how to remove/Improve "updating" everything.
One solution i did was change it to a coroutine.
I didn't really get a huge improvement,well kind of, its weird actually, i think the profiler just gave me inconsistent results as usual.
I've seen coroutines offer massive performance gains before, but who knows.

Let me know your thoughts.

Link to comment
Share on other sites

On 8/2/2016 at 11:15 AM, Kiori said:

@loodakrawa
Do you know what the current runtime overhead is?

I mean i imagine for a system running something like 20 different characters at once, with a implementation based on c# scripts, that can't be cheap.
But who knows.

If you have tested or have any experience let me know, I'm interested.

 

On 8/2/2016 at 1:50 PM, Kiori said:

I did a quick test with 30 chars, non-moving, animating, it seemed to be alright, but i'd have to check on mobile to be sure.
I noticed that in your main script "SpriterDotNetBehaviour.cs" you use Update. As per :http://blogs.unity3d.com/2015/12/23/1k-update-calls/
I did a few tests on how to remove/Improve "updating" everything.
One solution i did was change it to a coroutine.
I didn't really get a huge improvement,well kind of, its weird actually, i think the profiler just gave me inconsistent results as usual.
I've seen coroutines offer massive performance gains before, but who knows.

Let me know your thoughts.

Runtime overhead compared to what?

I've written the library to be as fast as possible (while still having readable code) and reduced memory allocations per frame to virtually zero.

However, if you have really a lot of animations you might have an impact on the CPU. The usual technique to solve this is caching computation results - like in the SnapshotAnimationDataProvider class. This drastically reduces CPU usage but uses more memory.

From my testing, the lib performs really well. The only  slow down I noticed is on Android (with > 30 complex animations) and the Profiler pinpointed the ApplySpriterTransform method, or more precisely, various calls to Unity's API inside the method. Unfortunately, I don't know if there's another, more efficient way of achieving the same thing in Unity.

Regarding coroutines, I don't think it makes much sense to use them here since the overhead of calling Update is probably negligible compared to other processing. But if you get positive improvements, let me know and I'll be more than happy to update the lib.

Cheers

Link to comment
Share on other sites

7 hours ago, winexploder said:

Hi,

 

thanks for the reply but I'm still not quite sure how that works. Just to clarify: This is supposed to work the same way as mecanim animation events, where a particular function is called at a certain frame?

Pretty much. The C# event is raised by the library when the event in Spriter animation occurs. You just have to register one or more methods to listen to the event (as in the examples).

Link to comment
Share on other sites

On 13/2/2016 at 8:48 PM, winexploder said:

Excuse my being dense but I still don't understand it. How do I get the method to call at the right time in the animation?

You register the methods you want with the EventTriggered event in *SpriterAnimator (as in the examples). Then the library raises the event at the right point during the animation which means you methods get called since you registered them with the event. If you look at the event signature, you'll see that it has a single string argument which represents the event name (as defined in spriter animation) - in other words, your listener method signatures must have a single string argument (again, take a look at the examples).

If you're still unclear about this - you should probably learn more about C# events.

Link to comment
Share on other sites

  • 2 weeks later...

Hey everyone!  I'm having a strange bug.  I have a bezier curve type on a mainline key in Spriter. In Unity, the data on the .asset file seems to be created correctly, but the interpretation of the data is wrong.  If I have animation on an object, the keyframes properly respect the mainline key curve type, but if I have animation on a bone, it completely ignores the curve type and defaults to what looks like a linear curve type.  If I manually edit the curve type on the timeline of the .asset file, the animation works as expected.  Why is bone data ignoring the curve type?

Link to comment
Share on other sites

On 26/2/2016 at 0:03 PM, steveEXC said:

Hey everyone!  I'm having a strange bug.  I have a bezier curve type on a mainline key in Spriter. In Unity, the data on the .asset file seems to be created correctly, but the interpretation of the data is wrong.  If I have animation on an object, the keyframes properly respect the mainline key curve type, but if I have animation on a bone, it completely ignores the curve type and defaults to what looks like a linear curve type.  If I manually edit the curve type on the timeline of the .asset file, the animation works as expected.  Why is bone data ignoring the curve type?

Hi,

Just trying to understand the issue - first you said that the data in the .asset file is correct but later you said you have to manually edit it. Could you post the relevant pieces of information? Additionally - could you upload the entire animation somewhere so I can take a look?

Link to comment
Share on other sites

Sure!  In the .asset file, I'm noticing the animation data primarily comes into the mainline animations.  In the inspector window in Unity, when I inspect the .asset file, I find the animation data under Spriter > Entities > Element 0 > Animations > Element 0 > Mainline Keys.  I see there's a second place where animation data goes.  This is located under Spriter > Entities > Element 0 > Animations > Element 0 > Timelines.  This is where I mentioned I can manually modify data here after it has been imported and it affects the animation.  Unless I'm misunderstanding, I shouldn't need to modify this data after it has been imported.

I've linked a .zip file with my Unity test project.  The included .scml in the TestBox folder has a green box with two identical very basic bounce animation.  Of the two animations that are on the box, one has the bounce animation data on the bone, one animation has it on the object.  When I import this .scml file into Unity, the object animation comes over correctly, but the bone animation treats the animation curve as if it's linear.  I created this project in Unity 5.3.0.

http://client.elementxcreative.com/spriter/SpriterTest.zip - Size: 0.11 MB

Link to comment
Share on other sites

8 hours ago, steveEXC said:

Sure!  In the .asset file, I'm noticing the animation data primarily comes into the mainline animations.  In the inspector window in Unity, when I inspect the .asset file, I find the animation data under Spriter > Entities > Element 0 > Animations > Element 0 > Mainline Keys.  I see there's a second place where animation data goes.  This is located under Spriter > Entities > Element 0 > Animations > Element 0 > Timelines.  This is where I mentioned I can manually modify data here after it has been imported and it affects the animation.  Unless I'm misunderstanding, I shouldn't need to modify this data after it has been imported.

I've linked a .zip file with my Unity test project.  The included .scml in the TestBox folder has a green box with two identical very basic bounce animation.  Of the two animations that are on the box, one has the bounce animation data on the bone, one animation has it on the object.  When I import this .scml file into Unity, the object animation comes over correctly, but the bone animation treats the animation curve as if it's linear.  I created this project in Unity 5.3.0.

http://client.elementxcreative.com/spriter/SpriterTest.zip - Size: 0.11 MB

This was caused by a bug in the core library. I fixed it and pushed to develop branch.

Thanks for reporting!

Link to comment
Share on other sites

  • 3 weeks later...

I appreciate the compliment.

It doesn't actually create any Mecanim animations (since that is unnecessary) so it's more of a "pseudo pretend Mecanim". The animation states are just empty shells that tell the SpriterAnimator what to do.

Here's the github link for anyone interested in tinkering with it.

https://github.com/Dharengo/SpriterDotNetMecanim

The main feature is basically for just basic statemachine-based animation, you use the AnimatorController just as you would with full Mecanim animations. With transitions, parameters and whatever you will. User-side scripts would communicate with the Animator component just like most Unity-users are used to.

There are a few caveats though. Unity's AnimatorController is quite... limited in its runtime accessibility. I already have to hop through a number of hoops just to make it possible to edit individual transition lengths. As such, some features might work a little differently than one would expect.

Animation blending and blend trees are a thing that don't work at this point in time, but substatemachines should work (in theory, it is untested).

Regarding the blending, I'm not sure if I CAN make it work. Like I said, the runtime accessibility, and even the edit time accessibility leave much to be desired.

That said, it appears that a future version of Unity will come with additional statemachine-based shenanigans, maybe the answer will lie therein.

Link to comment
Share on other sites

first of all: Thank you very much for your great work. The spriterdotnet.unity package is awesome.

I got one question though, but please do not laugh at me. I am very new to unity and spriter:

Is there a way to use the spriterdotnet.unity package to import spriter projects saved with the "generate spritesheets for project images" function in spriter? SpriterDotNet imports the project, but the sprite mode on the atlas sheet is getting setted as single, not as multiple. Don't know if this is my problem, but after dragging the animation to the scene, the sprites under the pivot nodes are referencing null (they look like this: Sprite: None (Sprite), and I get an "Argument cannot be null" exception in runtime. Am I using it wrong someway or is this simply not possible at the moment?

Thank you very much again, keep up the good work.
Michelle

Link to comment
Share on other sites

On 25.3.2016 at 2:53 PM, Dengar said:

I updated the project to also add a behaviour to the root StateMachine that lets you customize Any State transitions.

I really would appreciate it if people checked out the project and pointed out features that seem important but are currently missing.

Neat. I like this a lot. Definitly going to check it out. Thank you!

Link to comment
Share on other sites

Is there an example for handling everything at runtime that works with Unity 5.3?  I am asking as I have issues making things work.  I have simply created the Adventure Platformer Pack player as a spritesheeted project (File->"Generate spritesheets for project images" and selected "save spritesheeted project") and copied that to my assets.  Unity creates the prefab as expected, but that's where things come to a grinding halt.

if(spriterAnimator == null) 
{
	spriterBehaviour = player.gameObject.GetComponentInChildren<SpriterDotNetBehaviour>();
	spriterAnimator = spriterBehaviour.Animator;
	spriterAnimator.EventTriggered += e => Debug.Log("Event Triggered. Source: " + spriterAnimator.CurrentAnimation.Name + ". Value: " + e);
                
	foreach(string key in spriterAnimator.GetAnimations())
		Debug.Log("spriterAnimator.GetAnimations: " + key);

	spriterAnimator.Speed = 1.0f;
	spriterAnimator.Play("walk");
}

The code above seems to work, as in it produces valid objects and creates a debug output list of all animations, but nothing is ever rendered and an exception is thrown for every frame update:

ArgumentNullException: Argument cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary`2[UnityEngine.Sprite,System.Collections.Generic.KeyValuePair`2[System.Int32,System.Int32]].ContainsKey (UnityEngine.Sprite key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:458)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].GetSprite (SpriterDotNet.SpriterObject obj)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Animate (Single deltaTime)
SpriterDotNetUnity.UnitySpriterAnimator.Animate (Single deltaTime) (at Assets/SpriterDotNet/UnitySpriterAnimator.cs:44)
SpriterDotNet.SpriterAnimator`2[TSprite,TSound].Step (Single deltaTime)
SpriterDotNetUnity.SpriterDotNetBehaviour.Update () (at Assets/SpriterDotNet/SpriterDotNetBehaviour.cs:72)

I am certain I am doing things wrong, just not sure how or where ...  Any help or pointers are much appreciated!

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