Jump to content

Recommended Posts

 

1 hour ago, Chris said:

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!

 

SpriterDotNet.Unity works great for me, but it seems it does not support spriter spritesheet animations at this point in time. I would be very interested in this feature as well. It looks like the importer is not telling unity to make the imported sprite a multiple images type, and hence unity cannot populate the sprites in the prefab with sprite references, since they are just not available by name from a single type sprite. This makes the sprite argument null at runtime throwing the exception. Using the original spriter project instead of the generated spritesheet project should solve your problem right away. I know it is far better to use atlases for performance reasons, but in the meantime we can use it this way and correct this lateron. Hopefully this feature is developed on and available sometime soon. :) If so, THANK YOU SO MUCH loodakrawa! Love your work!

 

Link to post
Share on other sites
  • Replies 166
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

SpriterDotNet.Unity The Unity plugin for SpriterDotNet. Supports all Spriter features. https://github.com/loodakrawa/SpriterDotNet/tree/develop/SpriterDotNet.Unity Documentation The

SpriterDotNet is a library that does all the work in pure C# code in order to support all Spriter features and be able to work with any .net frameworks/platforms. Unfortunately that means that it does

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 tha

Posted Images

13 minutes ago, wagnmich@gmail.com said:

SpriterDotNet.Unity works great for me, but it seems it does not support spriter spritesheet animations at this point in time. I would be very interested in this feature as well. It looks like the importer is not telling unity to make the imported sprite a multiple images type, and hence unity cannot populate the sprites in the prefab with sprite references, since they are just not available by name from a single type sprite. This makes the sprite argument null at runtime throwing the exception. Using the original spriter project instead of the generated spritesheet project should solve your problem right away. I know it is far better to use atlases for performance reasons, but in the meantime we can use it this way and correct this lateron. Hopefully this feature is developed on and available sometime soon. :) If so, THANK YOU SO MUCH loodakrawa! Love your work!

Thanks a bunch, wagnmich@gmail.com.  Guess I'll give the regular spriter projects a try then.

Link to post
Share on other sites

I really recommend against using sprite sheets at this point in time. 

I don't know what loodakrawa thinks, but to be able to use a sprite sheet in such a manner would mean importing the sheet through script, then somehow, through script, slice the sheet to create the sprite references. I don't even know if this is possible, and I really have no motivation to find out.

There's also zero need for such a feature since Unity has the Sprite Packer.

I suppose there's ONE thing that's possible. But this also wouldn't use Spriter's sprite sheet functionality.

But basically, you just use separate files as normal, and then have a script in Unity automatically set the packing tags and generate the atlas. I'm fairly sure that's possible to do through script. If loodakrawa doesn't pick this up I might look into this myself.

Link to post
Share on other sites

 

3 hours ago, Dengar said:

I really recommend against using sprite sheets at this point in time. 

I don't know what loodakrawa thinks, but to be able to use a sprite sheet in such a manner would mean importing the sheet through script, then somehow, through script, slice the sheet to create the sprite references. I don't even know if this is possible, and I really have no motivation to find out.

There's also zero need for such a feature since Unity has the Sprite Packer.

I suppose there's ONE thing that's possible. But this also wouldn't use Spriter's sprite sheet functionality.

But basically, you just use separate files as normal, and then have a script in Unity automatically set the packing tags and generate the atlas. I'm fairly sure that's possible to do through script. If loodakrawa doesn't pick this up I might look into this myself.

I see, thank you. My prime motivation to use the spriter spritesheet function was the very clean asset directory. every spriter project eventually boils down to one json, png and scml file. I really really like it when things are tidy and easy. :) Dropping the whole spriter project into the unity assets seems a little messy to me. I have no idea how the asset packer for unity works. I think I should look into this matter next.

Link to post
Share on other sites

Well, the Unity manual has the explanation of how to use it, but basically it takes advantage of the fact that Unity uses its own graphic compression methods to put multiple sprites into a single atlas whenever you build the game. It has the advantage of making each individual sprite its own asset you can reference, but in the built game they are just an atlas and a set of coordinates.

Link to post
Share on other sites

Hi everyone - I won't quote individual posts since they're all about spritesheets. I'm definitely planning to add support for sprite atlases but I'll first do other things. The rough roadmap is:

  • finish the MonoGame plugin
  • fix open bugs
  • update the Unity plugin
  • implement atlases
  • implement blend trees (or an alternative)

@Dengar - I think Unity supports sprite "regions" or something similar so that's how I plan to do this. I can't remember exactly how that works but I remember seeing a similar functionality already

Link to post
Share on other sites
On 24.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.

This is a really helpful tool. Thank you!! Since you asked, it would be a great feature to get the mirror checkbox and the speed float input on an animation state to work. :)

Mike

Link to post
Share on other sites
On 02/04/2016 at 3:48 PM, mikesdevcorner said:

This is a really helpful tool. Thank you!! Since you asked, it would be a great feature to get the mirror checkbox and the speed float input on an animation state to work. :)

Mike

 

On 02/04/2016 at 10:48 PM, Dengar said:

I'm not entirely sure if I can do that. I can probably add something similar to the AnimatorRelay, provided that SpriterDotNet actually supports these features, I'm not sure if it does. @loodakrawa would know.

  • Speed - (Unity)SpriterAnimator has a Speed property
  • Mirror - to mirror the animation, changing the scale to negative on the top level object should do the trick
Link to post
Share on other sites
  • 2 weeks later...
On 3/28/2016 at 11:38 AM, Dengar said:

I really recommend against using sprite sheets at this point in time. 

I don't know what loodakrawa thinks, but to be able to use a sprite sheet in such a manner would mean importing the sheet through script, then somehow, through script, slice the sheet to create the sprite references. I don't even know if this is possible, and I really have no motivation to find out.

Hey just wanted to let you know that I'm pretty sure this is possible, and I believe that this library, https://bitbucket.org/Chaoseiro/x-unitmx/wiki/Home (an API to import maps made in the popular and free Tiled Map Editor) uses this technique. It finds the sprite sheets used in Tiled in your Resources folder, and slices them according to how they were slices in Tiled. You can probably look through it and find out how they do it if you're interested.

Link to post
Share on other sites
On 4/18/2016 at 11:48 AM, Dengar said:

What I am wondering is, though. What is the argument against just using the Sprite Packer?

Oh I'm not saying you should or anything, just that the technique you mentioned is possible (I think).

If Unity is already packing/compressing sprites when you build, then that's fine too. 

Link to post
Share on other sites
  • 2 months later...

Hello guys! 

Thanks for all the work you've put into this.

Just tried out this new package. Could you please help me figure out how to swap individual sprites during runtime? Tried replacing sprites on gameobject, but it seems to be resetting them every frame.

Edit: Ok, in case anybody wondering, solved by using "UnityAnimatorInstance.SpriteProvider.Set(folderid, fileid, mynewsprite)". Seems like not the most elegant solution, but gets the job done.

Edited by Andrey
Link to post
Share on other sites
On 16/07/2016 at 0:54 PM, Andrey said:

Hello guys! 

Thanks for all the work you've put into this.

Just tried out this new package. Could you please help me figure out how to swap individual sprites during runtime? Tried replacing sprites on gameobject, but it seems to be resetting them every frame.

Edit: Ok, in case anybody wondering, solved by using "UnityAnimatorInstance.SpriteProvider.Set(folderid, fileid, mynewsprite)". Seems like not the most elegant solution, but gets the job done.

Yes - that is the way to do it (if you're not using character maps). What would be the most elegant way? I'm always open for improvement ideas.

Link to post
Share on other sites
3 minutes ago, loodakrawa said:

Yes - that is the way to do it (if you're not using character maps). What would be the most elegant way? I'm always open for improvement ideas.

Didn't mean to critisize, sorry, just thought there is another, "intended", way to achieve the same goal (since it's a pretty basic feature) without using character maps.
I do have a question though, why do we have to refresh every sprite each frame?

protected override void ApplySpriteTransform(Sprite sprite, SpriterObject info)
        {
            . . .

            renderer.sprite = sprite;

            . . .
        }

we can comment out this line, and everything will be working fine, except for sprite swapping.

Link to post
Share on other sites
7 minutes ago, Andrey said:

Didn't mean to critisize, sorry, just thought there is another, "intended", way to achieve the same goal (since it's a pretty basic feature) without using character maps.
I do have a question though, why do we have to refresh every sprite each frame?


protected override void ApplySpriteTransform(Sprite sprite, SpriterObject info)
        {
            . . .

            renderer.sprite = sprite;

            . . .
        }

we can comment out this line, and everything will be working fine, except for sprite swapping.

No worries - I didn't get offended. I'm genuinely interested to find out if there's a better way of doing things - especially from a user's perspective. For me is hard to tell since I know the ins and outs of the library.

The sprite gets refreshed every frame because sprites can appear/disappear during the animation. In some cases this might be unnecessary and can be commented out but I don't think that impacts the performance in any significant way.

Link to post
Share on other sites
  • 4 weeks later...
On 26/07/2016 at 6:45 AM, iLLoren said:

Hi @loodakrawa .
I can not find a full documentation for SpriterDotNet. Can you tell where I can see more examples of the use of your solutions in practice?

In Unity.Examples insufficient information. For example tracking the progress of animation or use the system of Events.

Hi,

You can find the documentation here: https://github.com/loodakrawa/SpriterDotNet and here: https://github.com/loodakrawa/SpriterDotNet/tree/develop/SpriterDotNet.Unity

The example just shows a simple way of using the library but the documentation covers a lot more (including the animation progress and events).

Cheers

Link to post
Share on other sites
  • 3 months later...

So, I've been looking at Spriter as a tool for creating animated assets for a project I was thinking about and managed to run across this project.

The main issue I'm curious about is the ability to load .scml files at runtime, rather than via the editor.  The primary reason I'm curious about this is that I'd like the ability to users to customize or add content.  I should be able to still allow for user created content via asset packages, however, that requires they use Unity to package such content, whereas loading directly would not.

Appreciate any advice on this...

Thanks!

Link to post
Share on other sites
3 hours ago, Ecu said:

So, I've been looking at Spriter as a tool for creating animated assets for a project I was thinking about and managed to run across this project.

The main issue I'm curious about is the ability to load .scml files at runtime, rather than via the editor.  The primary reason I'm curious about this is that I'd like the ability to users to customize or add content.  I should be able to still allow for user created content via asset packages, however, that requires they use Unity to package such content, whereas loading directly would not.

Appreciate any advice on this...

Thanks!

I don't see why not - I suppose you could do something similar to what SpriterImporter does, just during runtime.

Link to post
Share on other sites
9 minutes ago, loodakrawa said:

I don't see why not - I suppose you could do something similar to what SpriterImporter does, just during runtime.

So, not something the system does by default, eh?  From the look of it, it would be quite a bit of work to re-engineer this to not generate assets and instead create correct game objects at runtime.  As I'm quite unfamiliar with the this kit yet...perhaps to keep it easy, I'll just use asset bundles.  I assume that it should be rather easy to just setup a simple project that people can load, dump Spriter folders into the assets and then export bundles.

Link to post
Share on other sites
36 minutes ago, Ecu said:

So, not something the system does by default, eh?  From the look of it, it would be quite a bit of work to re-engineer this to not generate assets and instead create correct game objects at runtime.  As I'm quite unfamiliar with the this kit yet...perhaps to keep it easy, I'll just use asset bundles.  I assume that it should be rather easy to just setup a simple project that people can load, dump Spriter folders into the assets and then export bundles.

I think you could reuse at least 90% of the code from the importer and just get rid of the UnityEditor specific stuff which is something you don't really need for runtime creation. This actually gives me an idea - it would probably be good to extract that functionality in the library itself and just use it in the importer. :-D

Link to post
Share on other sites
4 minutes ago, loodakrawa said:

I think you could reuse at least 90% of the code from the importer and just get rid of the UnityEditor specific stuff which is something you don't really need for runtime creation. This actually gives me an idea - it would probably be good to extract that functionality in the library itself and just use it in the importer. :-D

Heh.  I would definitely feel a whole lot more comfortable with you pulling that out than doing it myself.  If you were to do such a thing, would you be able to make editor generation a toggle as well?  That way I can keep the Spriter folders with the project, instead of it automatically generating prefabs.  Though I suppose I'm not sure if I want the Spriter folders in the assets directory if I want them to be copied into the runtime folder anyways.  It's been a bit of time since I last tried developing anything in Unity.

Link to post
Share on other sites
29 minutes ago, Ecu said:

Heh.  I would definitely feel a whole lot more comfortable with you pulling that out than doing it myself.  If you were to do such a thing, would you be able to make editor generation a toggle as well?  That way I can keep the Spriter folders with the project, instead of it automatically generating prefabs.  Though I suppose I'm not sure if I want the Spriter folders in the assets directory if I want them to be copied into the runtime folder anyways.  It's been a bit of time since I last tried developing anything in Unity.

The generation toggle sounds like a good idea. I'll implement it along with the other thing. Just as a heads up, it probably won't happen any time soon since I don't use Unity as the game dev platform of choice anymore.

Link to post
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...