How to change object's hierarchy level in animation?

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:

Before:

23535-before.png

After:

23533-after.png

How to do it painlessly?

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

UPDATE:

@gyd wrote a more elegant plugin that detects the hierarchy changes automatically:

GitHub Link

OLD ANSWER:

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.

Awesome script @s-m-k !

I created a simplified variant of it here:

Fixes the problem with rotation getting a keyframe on each frame!

Changes:

  • 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!

68652-screen-shot-2016-04-22-at-11154-pm.png

Try This one:
GitHub Link

Preview

Thanks for sharing this useful tool.
But I find that broken sprite animation is not listed in the animation hierarchy editor.

Seems like this script is not working anymore?`:(

Thanks! Just what I needed, works perfectly!