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
2
Question by hothead-brusnell · May 30, 2014 at 05:08 PM · gameobjectmeshanimatordestroycoroutine

Animator.Rebind() not working as expected after manually changing GameObject hierarchy

Hi,

At runtime, I am adding a new mesh to a GameObject (which has an Animator component). Once the mesh has been added to the GameObject (and the existing mesh has been removed), I grab the Animator component and call Rebind(). Unfortunately, the player stays in the default T-Pose.

However, if I:

1) Save the following attributes of the existing Animator component:

runtimeAnimatorController, avatar, applyRootMotion, updateMode, cullingMode

2) Destroy the existing Animator component

3) Yield until the end of the frame (so the Destroy operation has actually taken place)

4) Add a new Animator component and assign the attributes I saved in step #1

Then, my model animates as expected. Ideally, I would like to avoid using a coroutine, and simply call Rebind(). Given the above explanation, am I misusing Rebind()? Any recommendations?

Thanks, Brennan.

Comment
Add comment · Show 6
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 Tryz · Jun 14, 2014 at 02:11 AM 0
Share

Having the same issue.

I've created the ability to save the scene (think saved games). I can bring everything back as it was, but the Animator doesn't play. However, if I change any value in the Animator's Inspector (that I just deserialized), then it starts playing the animations.

I hoped Rebind() would fix the problem, and let me do all this through code. It worked, but only if I yield until the end of the frame (per your suggestion). :)

avatar image deram_scholzara Tryz · Sep 28, 2015 at 05:56 PM 1
Share

Yes, this unfortunately seems to be the only actual answer at the moment, which sucks, since it's undocumented.

So to be clear, to fix this I had to run Animator.Rebind() in a coroutine (IEnumerator) which first called "yield return new WaitForEndOfFrame()".

I haven't tried it, but I'd guess that calling it on the next frame would also work, as it would appear that a hierarchy change will not get picked up until after the next animation update.

I'm also going to file a bug on this, because calling Rebind() should just account for this automatically, ins$$anonymous$$d of having to force it.

avatar image Morgenstern_1 deram_scholzara · Mar 28, 2017 at 03:00 PM 0
Share

I realise this is an old thread, but did you get a bug logged for this? I've just discovered this exact issue/solution in Unity 5.6 so it's still around. I'll happily vote on a logged bug if there's one present.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

25 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

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

C# Gameobject Is Destroyed before Animation Plays 4 Answers

Problem with timed code-execution (audioplay and object destruction) 1 Answer

Can't remove component. MeshRenderer depends on it 1 Answer

Replace GameObject vs. replacing mesh and material? 2 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