I’m trying to set facial blend shapes in Unity. This script is attached to the Renderer_Avatar object below the avatar.
public class AnimationController : MonoBehaviour
{
SkinnedMeshRenderer skinnedMeshRenderer;
// Start is called before the first frame update
void Start()
{
skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer>();
Debug.Log("got renderer!");
Debug.Log (skinnedMeshRenderer);
Debug.Log(skinnedMeshRenderer.sharedMesh.blendShapeCount);
SetBlendShapeWeight("jawOpen", 1);
}
public void SetBlendShapeWeight(string blendShapeName, float weight)
{
for (int i = 0; i < skinnedMeshRenderer.sharedMesh.blendShapeCount; i++)
{
if (
skinnedMeshRenderer
.sharedMesh
.GetBlendShapeName(i)
.Equals(blendShapeName)
)
{
Debug
.Log("setting weight! for " +
blendShapeName +
" to " +
weight);
skinnedMeshRenderer.SetBlendShapeWeight (i, weight);
break;
}
}
}
// Update is called once per frame
void Update()
{
SetBlendShapeWeight("jawOpen", 1);
}
}
It works when I press play in Unity (mouth opens up), but not on the actual device (Vision Pro).