• Unity
  • Adding new animations to Mecanim Controller

Related Discussions
...

Hmmm... I've done some work with Mechanim states and such... I'll see if my programming buddy or I can solve this problem and share the script.

2 months later

Hello, i know this thread has been inactive for a couple of months but i came to share my solution to the same problem the opener asked about (since i'm having the same issue).

I use the spine animations in unity without baking them, instead i use a SkeletonAnimator with the auto-generated Mecanim controller.

What i did was create manually a new Animator Controller that uses the animations from the Spine-created controller, so when i export new animations from the Spine project i just delete the Spine-created animator and create it again with right click on the SkeletonData file -> Spine -> Instantiate (Mecanim).
And then i just drag & drop the new animations from the spine-created controller (from the project view) into my manually created animator controller (which has all the transitions and logic between states).

So my character on scene has its animator component using the AnimatorController i created manually.

I hope this workaround helps somebody, it's the best solution i came up with.

Cheers

4 days later

I am also having this problem without baking. According to clandestine, automatic update of the list of animations as children of the automatically generated Controller worked when not baking, and didn't work when baking. However, I am not baking, and still unable to get the automatic update to work.

Thanks for suggesting this work around, Pravus. I think I will have to use this method for now. This will be quite a hassle to re-link each animation to their respective states in the separate Controller, since these links are lost when you delete the auto-generated Controller, which carry all the animation clips. In addition, all of the in-animation events/function calls have to be recreated as well - all of this each time you export new animations from Spine.

It would be so great if someone could point us in the right direction.

will address this over the coming weekend.

Not sure what the exact issues are still but my work flow is:
1) Export to unity
2) Right click SkeletonData file - Instantiate (Mecanim)
3) Save to prefab, delete scene object
4) Ensure prefab has anim controller that is auto-generated
5) Update spine animation, even add a new one.. export to unity (direct file path to unity project)
6) auto generated controller has new animation, everything appears to still be in-tact.
7) Drag new animation clip to Animator window in unity for usage.

Nothing seems to be getting deleted.. not sure what could have possibly changed. I used to have issues but now I don't, sorry for not much info to go off of but somehow things work fine for our workflow. I have seen issues sometimes where the auto built animator won't update properly.

Do you guys all export directly into unity or are you trying to drag and drop files into the inspector etc? I build directly to file path IN my unity assets folder and wait a few seconds and then click into Unity to see changes. If for some reason the auto built controller doesn't update I export again and everything is good.

I'm happy to say that I've found the problem for my specific case. Hopefully this will help others as well.

The problem, for me, was adding extension .txt to the .json file as well, which I learnt from following this tutorial https://www.youtube.com/watch?v=x1umSQulghA, as was suggested in a few other posts. After reading a few threads on the forum, I've learnt that this used to be required in Unity 4.x. I suppose Unity 5.x can handle .json files now. I have reproduced this problem a few times by using .json.txt a few times, so I am certain that this was causing the Controller to not update itself when I re-exported from Spine.

Solution: I've deleted the previous Spine export files in Unity and re-exported them from Spine, this time adding only .txt to the .atlas file and leaving .json as it is, and now the auto-generated Animation Controller updates itself by adding/deleting animations as its children every time I export from my modified Spine project. Just awesome.

2 months later

Interesting you say that.. we didn't start using Spine really until Unity5 and I forgot to use .txt on the json file and yes everything does work correctly for us without using json.txt in U5.


19 Sep 2015, 12:12


Is this as easy as adding if(!clipTable.ContainsKey(o.name)) before line clipTable.Add(o.name, (AnimationClip)o); in SkeletonBaker around like 406? I added it and it now doesn't cause my issue and seems to remove/add/update new animations properly. I don't know of any adverse effects it could cause though.