The Animation View in Unity allows us to make references to objects (their properties, to be exact) with different hierarchy levels, so we can apply one animation to all objects that share certain structure. But what if I created, tested and polished a set of transitions on some object and now I want to nest it somewhere else in its parent (which holds the Animator Component)?
What I expected from the Animation View was an option to change "hierarchy level" of different properties (like changing indent level in some text editors), but I couldn't find anything like that. So, am I doomed to delete all properties and start over again with new references? Or edit the animation's file by myself?
I bet there's simpler and more sane solution to that problem, as it seems to be too obvious not to think about it in the development process of Unity. However, either I cannot phrase the question properly, or people haven't encountered that kind of problem before (or I'm just blind).
TLDR I want to do this:
How to do it painlessly?
If you need that functionality, you can vote for it here: http://feedback.unity3d.com/suggestions/ability-to-edit-object-hierarchy-in-animation-clip
I hope devs will provide it.
Thank you very much!! This script help me a lot!!
Answer by s-m-k
Mar 20, 2014 at 12:37 AM
Noone? It seems I had to solve that issue by myself.
I've written a simple editor to help fix broken animations. It should be pretty straightforward to use, but if you have some questions or found a bug, don't hesitate to contact me.
Here's the screen:
You can manage relative references by assigning a sample animated object to "Referenced Animator (Root)" (you can use prefabs here), then it will show you broken links (red color). You can then simply drag and drop child objects to the editor.
If you don't want to use any sample object, you can always edit paths manually, but you won't know if your paths are correct.
The code: https://github.com/s-m-k/Unity-Animation-Hierarchy-Editor/blob/master/AnimationHierarchyEditor.cs
Put it in YourProject/Editor folder to make it work, you'll find it in "Window > Animation Hierarchy Editor".
UPDATE: now my code should support sprite animations (and other object reference curves). I hope that it will save your time.
Am gonna throw some thanks this way. This is just the thing I needed.
Glad to hear that I was not alone with this problem :)
This really helped me in fixing some broken animations. Very useful tool which will almost certainly come in handy again. Thanks very much.
Thanks, your script is awesome !!!
I have created a new version of this editor which allows you to multi-select animations to mass-update multiple animations.
This was super helpful for importing a Spriter object and mass-replacing the references.
I've created a pull request in GitHub.
Answer by Panzermjau
Apr 22, 2016 at 08:16 PM
Awesome script @s-m-k !
I created a simplified variant of it here:
Fixes the problem with rotation getting a keyframe on each frame!
Instead of going via Unity's AssetDatabase API it reads the .anim files as raw text and replaces the path within them.
Removed the individual path remapping to new GameObject stuff.
Requires your assets to be serialized as text: Edit / Project Settings / Editor / Asset Serialization / Force Text
Hope people find it useful!
Nice, +1. How unprofessional on Unity's side though, that they still didn't fix that workflow-breaking issue by themselves after 2 years.
Odd problem I had with variant. Seemed the greater the hierarchy, the more time it took to process. Had a 3rd child running for about 15minutes (very fast PC), didn't bother waiting for a 4th child. Excellent if only not for that problem.
Answer by ofusion
May 12, 2014 at 06:59 AM
Thanks for sharing this useful tool. But I find that broken sprite animation is not listed in the animation hierarchy editor.
Maybe the sprite animation is root animation? The tool cannot list root afair, but I'll look at it later.
I've checked it and yeah, you're right, AnimationUtility.GetCurveBindings seem to ignore the sprite property :(
I don't know how to fix it at the moment (besides editing the binary file), but maybe there is a way to get also that kind of stuff.
I wonder why the Unity staff didn't implement such utility by themselves, maybe it's time to send a feature request?
I've updated my code, so it supports object reference curves (including sprite animations): https://github.com/s-m-k/Unity-Animation-Hierarchy-Editor/blob/master/AnimationHierarchyEditor.cs
Answer by Dev6_RC
Jul 02, 2014 at 02:28 PM
Seems like this script is not working anymore?`:(
I'll look at it when I have time.
I've just successfully used this tool to edit animation, can you be more specific about your problem?
Thank you, s-m-k! I think this just saved my butt on a tight deadline.
Answer by vladimirta89
Jun 13, 2016 at 06:08 AM
Thanks! Just what I needed, works perfectly!
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
41 People are following this question.
How animation tow objects in different time sequential
Simple character 2D-animation! (iOS)
Keeping gun on straight axis
Can you add animations from one rigged character to another using Mecanim?
Animation files (FBX) change when importing