-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBlendshapeEmphasis.cs
More file actions
39 lines (34 loc) · 1.51 KB
/
BlendshapeEmphasis.cs
File metadata and controls
39 lines (34 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlendshapeEmphasis : MonoBehaviour
{
[Header("Expression tuning")]
public float browEmphasis = 1;
public float eyeEmphasis = 1;
public float cheekEmphasis = 1;
public float noseEmphasis = 1;
public float mouthEmphasis = 1;
public float jawEmphasis = 1;
private SkinnedMeshRenderer smr;
private Mesh mesh;
private int blendShapeCount;
// Start is called before the first frame update
void Start()
{
smr = GetComponent<SkinnedMeshRenderer>();
mesh = smr.sharedMesh;
blendShapeCount = smr.sharedMesh.blendShapeCount;
}
private void LateUpdate() {
for (int i = 0; i < blendShapeCount; i++) {
string name = mesh.GetBlendShapeName(i);
if (name.Contains("Brow")) smr.SetBlendShapeWeight(i, smr.GetBlendShapeWeight(i) * browEmphasis);
if (name.Contains("Eye")) smr.SetBlendShapeWeight(i, smr.GetBlendShapeWeight(i) * eyeEmphasis);
if (name.Contains("Cheek")) smr.SetBlendShapeWeight(i, smr.GetBlendShapeWeight(i) * cheekEmphasis);
if (name.Contains("Nose")) smr.SetBlendShapeWeight(i, smr.GetBlendShapeWeight(i) * noseEmphasis);
if (name.Contains("Mouth")) smr.SetBlendShapeWeight(i, smr.GetBlendShapeWeight(i) * mouthEmphasis);
if (name.Contains("Jaw")) smr.SetBlendShapeWeight(i, smr.GetBlendShapeWeight(i) * jawEmphasis);
}
}
}