Animator.Rebind() issues

I have code from a previous project (5.6.0) where I could successfully add a mesh to a controller with an Animator component using the following code:

 model.transform.SetParent (controller.transform);
model.transform.localPosition = Vector3.zero;
controller.GetComponent<Animator>().Rebind();

The code was adapted from @MysterieCatGames 's 2015 Answer post here.

This allowed the skinned mesh renderer of the new mesh to be animated by the Animator of the controller despite not being bound at app initialization.

In 2017.1.0b10, this no longer works. The new mesh just stays in their T-pose, despite the Animator’s settings matching those of an Animator that was initialized with a mesh from the start. I can see the animation state (Grounded) playing in the Animator window when I have the controller selected, but the mesh isn’t updating to match.

Did Animators change somehow and there’s now a different way of binding a new mesh at runtime? Or is this a bug?

So after loads of tinkering last night, it seems Rebind() will work if there’s no mesh assigned to it to start. I had a mesh that was disabled, and adding another active mesh was not kosher with Rebind. But if the Animator starts out with no child SkinnedMeshRenderer, adding one and calling Rebind will allow it to be animated by the Animator.

Sort of a long shot throwing this question here, but might as well try: Anyone know of a way to call Rebind() without restarting the playing animation? I’ve tried some methods I found that involve saving all the Animator’s properties first inside a coroutine, then yielding until frame end and then using Play to call the animation at its previous time. The problem with this is that waiting til the end of the frame causes a flash of the character’s T-pose that looks worse than starting the animation over.

@Schneider21 Please file a bug with a small(ish) repro. This is definitely not on purpose.

1 Like