UnityEngine.SkinnedMeshRenderer.SetBlendShapeWeight C# (CSharp) Method

SetBlendShapeWeight() private method

private SetBlendShapeWeight ( int index, float value ) : void
index int
value float
return void
        public extern void SetBlendShapeWeight(int index, float value);

Usage Example

コード例 #1
2
    // TODO: Put this into Misc class?
    private void CreateBlendMesh(SkinnedMeshRenderer skinnedMeshRenderer, Mesh skinnedMesh, string name, bool convex)
    {
        // Detecting how many BlendShapes we have.
        int blendShapeCount = 0;
        blendShapeCount = skinnedMesh.blendShapeCount;
        Debug.Log("BlendShape count bottom: " + blendShapeCount);

        // Applying BlendShapes.
        if (blendShapeCount != 0)
            skinnedMeshRenderer.SetBlendShapeWeight(0, size * 100);

        // Creates a snapshot of the SkinnedMeshRenderer and stores it in the mesh.
        // That skinned mesh renderer should have the shape with the BlendShapes applyied.
        Mesh bakedMesh = new Mesh();
        skinnedMeshRenderer.BakeMesh(bakedMesh);

        // Recalcultate the bounding volume of the mesh from the vertices.
        bakedMesh.RecalculateBounds();
        Debug.Log("Baked mesh bounds: " + bakedMesh.bounds.ToString());

        // Selecting part and destroying MeshCollider in case there is one.
        GameObject child = transform.FindChild(name).gameObject;
        DestroyImmediate(child.GetComponent<MeshCollider>());

        // Adding MeshCollider and assigning the bakedMesh.
        MeshCollider meshCollider = child.AddComponent<MeshCollider>();
        meshCollider.sharedMesh = bakedMesh;
        meshCollider.convex = convex;
    }
All Usage Examples Of UnityEngine.SkinnedMeshRenderer::SetBlendShapeWeight