Jump to content

Spriter for Unity 5.0


Dengar
 Share

Recommended Posts

Hi, is there any possibility to make it so that the animation events don't get overwritten?

 

Basically I want to manually go in my animation in unity, and add events myself. But when the spriter file gets updated, these events will disappear.

Would it be possible for it to read where the events were, remember them, and add them to the newly imported animation? This would be amazing c:

Link to comment
Share on other sites

Hi, is there any possibility to make it so that the animation events don't get overwritten?

 

Basically I want to manually go in my animation in unity, and add events myself. But when the spriter file gets updated, these events will disappear.

Would it be possible for it to read where the events were, remember them, and add them to the newly imported animation? This would be amazing c:

 

The DX version does nothing with events (precisely because of what you just said). Are you using the Mythgarr version?

Link to comment
Share on other sites

The DX version does nothing with events (precisely because of what you just said). Are you using the Mythgarr version?

 

Huh, I'm using the DX version, I just switched from the old one. D: Am I doing something wrong?

 

Edited the animation and updated the prefab. But whenever it reimports the events are just lost..

Link to comment
Share on other sites

Is the old version still in your project by chance?

 

...Also, looking at my code I suddenly realise something. See, reimporting works by basically deleting the old and then recreating it.

 

There should be a few lines of code that basically grabs all the events from the previous version and copies them into the new version, but apparently I forgot to add that.

 

As a "quick fix", open AnimationBuilder.cs and find the following block of code:

if (OriginalClips.ContainsKey (animation.name)) { //If the clip already exists, copy this clip into the old one	var oldClip = OriginalClips [animation.name];	EditorUtility.CopySerialized (clip, oldClip);	clip = oldClip;	ProcessingInfo.ModifiedAnims.Add (clip);

Then insert a few lines

if (OriginalClips.ContainsKey (animation.name)) { //If the clip already exists, copy this clip into the old one	var oldClip = OriginalClips [animation.name];        var cachedEvents = oldClip.events;	EditorUtility.CopySerialized (clip, oldClip);	clip = oldClip;        AnimationUtility.SetAnimationEvents (clip, cachedEvents);	ProcessingInfo.ModifiedAnims.Add (clip);

That should fix your problem.

 

I'll also add this to the list of known issues.

Link to comment
Share on other sites

It's not really a solution, but for people who are suffering from the infinite loop bug,  you can change a couple things in ScmlPostProcessor.cs.
 
Add a list to cache the cache:

private static IList<string> lastCachedPaths = new List<string>();

In OnPostProcessAllAssets() just before cachedPaths.Clear():

lastCachedPaths = new List<string>(cachedPaths);

In ProcessFiles(), just before cachedPaths.Add(path) add:

if (lastCachedPaths.Contains(path)) {    Debug.LogError("Infinite loop on: " + path);    continue;}

and after the foreach loop, before the end of the function:

lastCachedPaths.Clear();

It checks that the same file isn't being processed more than twice and, if it is, breaks out of the loop and logs an error.

Obviously it doesn't fix anything, the assets don't get imported properly, but it stops your editor from locking up!

Link to comment
Share on other sites

Forget my last post, I found the bug in PrefabBuilder.cs, GetSpriteAtPath():

if ((importer.textureType != TextureImporterType.Sprite || importer.spritePivot.x != file.pivot_x     || importer.spritePivot.y != file.pivot_y) && !InvalidImporters.Contains (importer))

Where it says importer.spritePivot.y != file.pivot_y, it should be importer.spritePivot.y != 1-file.pivot_y.

 

EDIT: made a pull request just to save you some time.

Link to comment
Share on other sites

Updated the source folder as well as the package to v1.0.4. Contains a few minor fixes:

 

-AnimationEvents are now preserved between reimports

-SpriteSwapper renamed to TextureController to avoid confusion

-Fixed a z-position issue with the SortingOrderUpdater

 

I decided to wait with implementing the above fix until I know what it does exactly.

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

I tried for the first time the plugin and I got this error : 

 

InvalidOperationException: 'bezier' is not a valid value for Spriter2UnityDX.Importing.CurveType.

 

Then no prefab or animationController are created. 

 

Any idea why I get this error message and what I have to do to fix that ?

 

Thank you

Link to comment
Share on other sites

I'm no expert on Spriter2Unity, but it sounds like you used custom speed curves in one or more animation, and Spriter2Unity does not (yet at least) support anything but the standard linear easing of key-frames.

 

Hopefully someone else can confirm this, or remove any custom curves in a back-up of your Spriter project, and try importing the one with no custom curves.

 

cheers.

Link to comment
Share on other sites

Gots a quickfix for you that will fix the error (but won't actually implement the curve type):

-Open the file "ScmlSupport".

-Find the "CurveType" enum.

-Add the word "bezier" to the list of possible CurveTypes.

 

Basically, the short story is, the documentation never mentioned anything about a "bezier" curve type.

 

That said, while the enum is there in the file, it's really just a thing for future implementations. The CurveType enum doesn't actually DO anything at this point in time.

Link to comment
Share on other sites

  • 3 weeks later...

I'm wondering is it possbile to seperate animations from my character prefab? I have a lot of prefabs that use the same animations so I would like to use same animations for the different prefabs. So my question is, how to stop nesting of the animation? I don't know if this was answered before but I couln't find it.

Thanks in advance!

Link to comment
Share on other sites

Because the player character has a lot of different skins, and every skin has a few different options for itself also, and those options differ from skin to skin. So my plan was to create seperate prefab for every skin, so it can be unique but still use same animations

Link to comment
Share on other sites

Another feature planned for a future version is some implementation for CharacterMaps. That theoretically lets you store all your skin data in the prefab, or maybe a collection of ScriptableObjects, I haven't figured that part out.

I understand your idea though. At the moment I'm not in a position to make one of those "Quick fixes" though, maybe this weekend I'll write up a quick fix, or someone else can write one up.

Link to comment
Share on other sites

Alright, I have an update on the matter. I made a sort of intermediary build of the importer.

 

You can now from the main menu go Edit > Project Settings > Spriter2UnityDX.

 

There you can select whether you want your animations to be nested in the prefab, or placed in a separate folder.

 

I won't up the version number because as of today it's really just a very fast and crude solution that may cause some unexpected behavior if you try some weird things. Also it's fairly untested. Try it and see if you like the results.

Link to comment
Share on other sites

Woah, thanks a lot man... I really didn't expect anything, I was just curious about this feature, and you went and created it.. I really really appreciate it since I was struggling with the old Malhavok Spriter2Unity.

I will test it out later today for my purposes and report back.

Link to comment
Share on other sites

Okay I've tested it out and it works perfectly, thanks again. Except for the fact that pivots got to be custom and not center, but I saw that was planned for future. Because apart from my default sprites for the default prefab, other sprites have a bit bigger resolution (e.g. baggier shirt), but I played a bit with pivot X,Y, and got it working for now. So like I said, everything is perfect, you saved me

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.

 Share

  • Recently Browsing   0 members

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