按名称而不是索引获取混合形状

时间:2014-03-27 17:16:00

标签: c# unity3d

在Unity3d中,是否可以按名称而不是索引访问混合形状?

float currentShape= myObj.GetBlendShapeWeight(2); //index 2
float currentShape= myObj.GetBlendShapeWeight.GetByName("Gwen_Stefani");

1 个答案:

答案 0 :(得分:3)

想出来:

public string [] getBlendShapeNames (GameObject obj)
{
    SkinnedMeshRenderer head = obj.GetComponent<SkinnedMeshRenderer>();
    Mesh m = head.sharedMesh;
    string[] arr;
    arr = new string [m.blendShapeCount];
    for (int i= 0; i < m.blendShapeCount; i++)
    {
      string s = m.GetBlendShapeName(i);
      print("Blend Shape: " + i + " " + s);
      arr[i] = s;
    }
    return arr;
}