• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
11
Question by s-m-k · Mar 12, 2014 at 07:06 PM · animationobjectschangehierarchy

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:

Before

After:

After

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.

after.png (9.2 kB)
before.png (10.2 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by gyd · May 10, 2017 at 07:38 PM

Try This one: GitHub Link

Preview

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image s-m-k · Jul 05, 2017 at 10:28 AM 0
Share

Looks pretty good, why does the link not work?

I think it should replace my ad-hoc version.

avatar image gyd · Jul 05, 2017 at 10:33 AM 1
Share

Because I add a readme for the script, thanks for feedback. Now it has been fixed. :)

avatar image algaib · Oct 03, 2021 at 05:40 AM 0
Share

This looks amazing! Unfortunately I can't seem to get it working. Can you explain the steps to set it up please? Thanks

avatar image
46

Answer by s-m-k · Mar 20, 2014 at 12:37 AM

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:

Animation Hierarchy Editor

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.


hierarchy.png (12.8 kB)
Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Xelnath · Mar 18, 2015 at 04:13 AM 2
Share

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.

avatar image seantheyahn · Apr 07, 2015 at 06:05 PM 0
Share

Tnx! You saved me a lot of time! Though I commented out a part of the code, because I had two references to the same object with different properties (thething : position and thething : rotation) and this part of code prevented me from changing the reference.

 void UpdatePath(string oldPath, string newPath) 
     {
         //if (paths[newPath] != null) {
         //    throw new UnityException("Path " + newPath + " already exists in that animation!");
         //}

 
avatar image blamejane · May 31, 2015 at 12:52 PM 0
Share

I guess I'm the only one having difficulty understanding this script. I've been able to drag and drop to fix red broken links, but what does the "change" button do, and what are the numbers (change 1, change 2,...) next to the change button mean? Lastly, what is the replace root for? Looks like it only takes string values. Thanks, I really hope someone can explain this cuz I've been trying to fix my animations for hours and I am not making much progress. :(

avatar image s-m-k · May 31, 2015 at 03:40 PM 0
Share

From what I understand (I'm not the only contributor now) the "Change" is meant to apply the new path (i.e. actually save to the animation file) and "replace root" changes all paths according to the new root, e.g., if you have Animator component attached to "OldRoot" object and animate "NewRoot/SomeObject1" and "NewRoot/SomeObject2", you can change the root to "NewRoot" and paths will be automatically changed to "SomeObject1" and "SomeObject2".

avatar image s-m-k · Mar 20, 2017 at 06:04 PM 1
Share

@jcuriel free.

Show more comments
avatar image
5

Answer by Panzermjau · Apr 22, 2016 at 08:16 PM

Awesome script @s-m-k !

I created a simplified variant of it here:

  • View: http://pastebin.com/nPGzSPv3

  • Download: https://drive.google.com/file/d/0ByYfMpnZHzr9WHJGT3VoVVZFdjQ/view

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!

alt text


screen-shot-2016-04-22-at-11154-pm.png (38.0 kB)
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image s-m-k · Apr 22, 2016 at 09:28 PM 0
Share

Nice, +1. How unprofessional on Unity's side though, that they still didn't fix that workflow-breaking issue by themselves after 2 years.

avatar image rookiemistakes · Oct 21, 2016 at 03:13 PM 0
Share

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 15$$anonymous$$utes (very fast PC), didn't bother waiting for a 4th child. Excellent if only not for that problem.

avatar image
0

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image s-m-k · Jul 02, 2014 at 02:32 PM 0
Share

$$anonymous$$aybe the sprite animation is root animation? The tool cannot list root afair, but I'll look at it later.

avatar image s-m-k · Jul 09, 2014 at 11:09 PM 0
Share

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?

EDIT: http://feedback.unity3d.com/suggestions/ability-to-edit-object-hierarchy-in-animation-clip

avatar image s-m-k · Nov 06, 2014 at 06:21 PM 0
Share

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

avatar image bobmoff · May 20, 2015 at 08:35 AM 0
Share

thx @s-m-k

avatar image
0

Answer by RChrispy · Jul 02, 2014 at 02:28 PM

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

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image s-m-k · Jul 02, 2014 at 02:32 PM 0
Share

I'll look at it when I have time.

avatar image s-m-k · Jul 09, 2014 at 10:46 PM 0
Share

I've just successfully used this tool to edit animation, can you be more specific about your problem?

avatar image Dave Taylor · Jul 25, 2014 at 12:14 AM 0
Share

Thank you, s-m-k! I think this just saved my butt on a tight deadline.

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

46 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Change position - cameras - slider 1 Answer

Using the same animation on duplicate objects. 2 Answers

Can the animation editor create local rotational data? 3 Answers

Having trouble changing sprites in 2 dimensional animation 1 Answer

How Change one object to another in animation? ( change Sphere to cube) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges