Search Unity

Question Blend Shape missing in animation clip copied to new mesh

Discussion in 'Animation' started by syobe0808, Nov 2, 2021.

  1. syobe0808

    syobe0808

    Joined:
    May 17, 2017
    Posts:
    8
    I copied blend shape origin mesh to new mesh.
    It seems to copy completely as you can see below screenshot. But It's not working in animation.

    Mesh sourceMesh = _smRenderers[i].sharedMesh;
    Mesh targetMesh = smr.sharedMesh;
    Vector3[] deltaVertices = new Vector3[sourceMesh.vertexCount];
    Vector3[] deltaNormals = new Vector3[sourceMesh.vertexCount];
    Vector3[] deltaTangents = new Vector3[sourceMesh.vertexCount];
    for(int shapeIndex = 0; shapeIndex<sourceMesh.blendShapeCount; ++shapeIndex)
    {
    string shapeName = sourceMesh.GetBlendShapeName(shapeIndex);
    if(targetMesh.GetBlendShapeIndex(shapeName) < 0)
    {
    int frameCount = sourceMesh.GetBlendShapeFrameCount(shapeIndex);
    for(int frameIndex = 0; frameIndex<frameCount; frameIndex++)
    {
    float frameWeight = sourceMesh.GetBlendShapeFrameWeight(shapeIndex, frameIndex);
    sourceMesh.GetBlendShapeFrameVertices(shapeIndex, frameIndex, deltaVertices, deltaNormals, deltaTangents);
    targetMesh.AddBlendShapeFrame(shapeName, frameWeight, deltaVertices, deltaNormals, deltaTangents);
    }
    }
    }


    this is my copy code.
    (it refered https://extra-ordinary.tv/2020/09/07/copying-blendshapes-in-unity-with-a-script)

    So I check animation clip in animation window. Blend shape in animation clip is missing.
    I think link is broken during copy mesh to mesh. blendshape.jpg


    can Unity Technology guys help me ?
     
    Last edited: Nov 24, 2021