Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by caardappel-hbs · Feb 14, 2013 at 11:41 PM · animationmemoryaddclip

Animation.AddClip() copies the clip?

I just want to confirm if this is Unity, or something I'm doing. I have an object that acts as an animation library and when characters are loaded into the scene they fill out their Animation components by using .AddClip and sourcing from the library. Whenever a clip is added it appears to be duplicated in memory. Is this normal behavior for Unity or am I leaking something somewhere?

Thanks!

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

1 Reply

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

Answer by disturbing · Oct 28, 2013 at 03:36 PM

This is a really late reply, but I found the issue!

I have multiple animations and 3 different rigs, so I decided to rename all the animation clips when adding them to the Animation class. (This is using legacy Animation, not Mecanim)

So for instance

Spider_Idle Raptor_Idle

Became just "Idle" in the Animation.

 AnimationClip animClip = animationContainer.AnimationClip;
 string name = animClip.name.Substring(animClip.name.IndexOf('_') + 1);
 
 animation.AddClip(name , animClip);


If name != anim.Clip.name, you will get duplicated animations in memory, every time you AddClip.

So, the solution that fixed our problem was dynamically renaming the animation clip

 AnimationClip animClip = animationContainer.AnimationClip;
 animClip.name = animClip.name.Substring(animClip.name.IndexOf('_') + 1);
 
 animation.AddClip(animClip.name, animationContainer.AnimationClip);


Hope this helps anyone with this issue. I'm reporting it as a bug to Unity.

Comment
Add comment · Show 1 · 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 Arycama · Feb 09, 2018 at 02:50 PM 0
Share

Thanks for this, despite it being 5 years ago this still hasn't been fixed. I assume this is because the legacy animation system is to be eventually replaced by mecanim.

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

13 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

Related Questions

Added animation not Playing 0 Answers

Can the animation editor create local rotational data? 3 Answers

Adding animation clips via script 2 Answers

Not playing whole animation 0 Answers

Game works fine in the editor, but glitching on build 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