按名称而不是按索引获取blendshapes
本文关键字:索引 获取 blendshapes | 更新日期: 2023-09-27 17:54:01
在Unity3d中,是否可以通过名称而不是通过索引访问blendshapes ?
float currentShape= myObj.GetBlendShapeWeight(2); //index 2
float currentShape= myObj.GetBlendShapeWeight.GetByName("Gwen_Stefani");
figure out:
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;
}