在Unity3d中,是否可以按名称而不是索引访问混合形状?
float currentShape= myObj.GetBlendShapeWeight(2); //index 2
float currentShape= myObj.GetBlendShapeWeight.GetByName("Gwen_Stefani");
答案 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;
}