Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by lordlycastle · Jul 03, 2019 at 10:49 AM · animatoreditor-scriptinganimator controlleranimationclipassetdatabase

How to move Animation Clips into Animator Controller?

How can I move my own animation clips into an animation controller so it is a child in the project hierarchy. See pic below. I want them to be children of the controller so it is easier to maintain the project structure and know which clip belongs to which controller e.g. here all the new clips belong to More Button Controller. folder-hierarchy

I've tried what is suggested here. It doesn't work with existing clips. It throws an error saying 'Clip already exists'.

I also tried removing and adding it and it does show up correctly in hierarchy but it also keeps the old copy. So now there are two items in the project window.

 AssetDatabase.RemoveObjectFromAsset(animationClip);
 AssetDatabase.AddObjectToAsset(animationClip, animatorController);

I've also tried AssetDatabase.MoveAsset where new location is AnimationController/ClipName. That doesn't work either; it says 'Cannot move.'

Is there no way to move existing clips to animator controller?

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

2 Replies

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

Answer by lordlycastle · Jul 03, 2019 at 04:51 PM

I was able to finally do this by creating a copy and then moving that into the object. It however, does not update it's references. So you'll have to manually replace the old ones. So it is best to do this in start.

NOTE: once you add it to asset I was not able to find a way to remove it! So create backup/VC.

     /// <summary>
     /// Moves existing animation clips to be part of animator controller.
     /// It does this by creating a copy and then adding a copy. It has option to delete the old copy.
     /// </summary>
     /// <param name="animationClip"></param>
     private void CopyExistingClip(AnimationClip animationClip)
     {
         var newCopy = Object.Instantiate(animationClip) as AnimationClip;
         newCopy.name = animationClip.name;

         AddClipToAnimatorController(newCopy);
         if (deleteOldCopies)
         {
             AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(animationClip));
         }
     }

     /// <summary>
     /// Creates a new clip and adds it to the animator controller.
     /// </summary>
     /// <param name="clipName"></param>
     private void CreateNewAnimationClip(string clipName)
     {
         var newClip = new AnimationClip {name = clipName};
         AddClipToAnimatorController(newClip);
         
     }

     /// <summary>
     /// Add the clip to animator controller and re-imports
     /// </summary>
     /// <param name="animationClip"></param>
     private void AddClipToAnimatorController(AnimationClip animationClip)
     {
         AssetDatabase.AddObjectToAsset(animationClip, animatorController);
         AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(animationClip));
     }
Comment
Add comment · 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
0

Answer by danielandrino · Jul 22, 2020 at 02:20 PM

There is a easier way of moving an animation clip to a new controller.

  1. Create the new Controller

  2. In the Animator window, add a new empty state

  3. Select the created state and update the motion parameter (in the inspector window) with the old animation clip

  4. You will need to manually update the animation clip references. In the Hierarchy window, select the object containing the new controller. In the Animation window, select the clip and then click twice (not double click) in each of the missing references text. Update the text to the new hierarchy structure.

Hope it helps!

Comment
Add comment · 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

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

144 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to interrupt and replay an animation? 0 Answers

Animator Controller 2D RPG Best Practices 0 Answers

AnimatorOverrideController not working 0 Answers

How to get reference to a specific Animation Clip in Animator. 0 Answers

How to synchronize child animation with parent ? 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