Get blendshapes by name

Is it possible to access blendshapes by name instead of index?

Instead of

float currentShape= myObj.GetBlendShapeWeight(4); //index 4

have something like

float currentShape= myObj.GetBlendShapeWeight.GetByName("FightingLlamaStance");

2 Answers

2

.sharedMesh.GetBlendShapeIndex

in your case something like
myObj.sharedMesh.GetBlendShapeIndex(“FightingLlamaStance”);

Not as easy as I had hoped, but I got there in the end:

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); // Blend Shape: 4 FightingLlamaStance
      arr *= s;*

}
return arr;
}