Firstborn/Assets/RPG Creation Kit/Scripts/Character System/Scripts/HeadBlendshapesManager.cs
Schaken-Mods 959e80cf72 assets upload
assets upload description.
2023-03-28 12:16:30 -05:00

43 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RPGCreationKit;
namespace RPGCreationKit
{
/// <summary>
/// Manages the child blendshapes of the Head, like eyes, mouth, etc. I.E. Moves Eye's blendshapes in the same position of the eye socket position of the Head Mesh.
/// </summary>
// public SkinnedMeshRenderer Hair;
[System.Serializable]
struct BlendshapeChildOfHead
{
public SkinnedMeshRenderer meshRenderer;
}
public class HeadBlendshapesManager : MonoBehaviour
{
[SerializeField] SkinnedMeshRenderer headMesh;
[SerializeField] public SkinnedMeshRenderer HairMesh;
[SerializeField] BlendshapeChildOfHead[] blendshapesChildOfHead;
public void AdjustChildBlendshapes()
{
for (int i = 0; i < blendshapesChildOfHead.Length; i++)
{
SetBlendShapes(blendshapesChildOfHead[i].meshRenderer);
}
SetBlendShapes(HairMesh);
}
public void SetBlendShapes(SkinnedMeshRenderer a)
{
for (int k = 0; k < a.sharedMesh.blendShapeCount; k++)
{
a.SetBlendShapeWeight(k, headMesh.GetBlendShapeWeight(k));
}
}
}
}