Hi,
I’m trying to replace skinned mesh (sold3 is the parent object which encapsulate the mesh) in game object (GameObject object, see below) that has associated some animator using script (“Test” is testing script which replace the mesh, see below). But when mesh is replaced (as whole with bones) the animation isn’t playing anymore and mesh is in T-pose. But if I for instance deactivate/activate parent GO (“GameObject” GO in hierarchy, see below) then animation begins to play as usual (same happens if I enable/disable root motion in animator). It looks like the animator isn’t informed that mesh has changed or something like that.
Is this bug or could I somehow tell the animator to “refresh” itself?
My game object hierarchy is as follow:
GameObject [Animator][Test]
| - sold3
| | - mesh [SkinnedMeshRenderer]
| + - hips
|
Replace
| - mesh [SkinnedMeshRenderer]
| - hips
GameObject is parent of sold3. sold3 is parent of mesh, hips.
Replace is parent of mesh, hips.
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour
{
public GameObject original;
public GameObject replace;
// Use this for initialization
void Start ()
{
StartCoroutine(test());
}
IEnumerator test()
{
yield return new WaitForSeconds(2);
// Remove old combined mesh
Destroy(original);
replace.SetActive(true);
replace.transform.parent = transform;
replace.transform.localPosition = Vector3.zero;
}
}
Thank You