1234567891011121314151617181920212223242526272829303132333435 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using WebTools.Customizes.Behaviours;
- public class NpcFaceShapeChanger : MonoBehaviour
- {
- [System.Serializable]
- public struct ShapeStruct
- {
- public BlendShapeType blendShapeType;
- public string blendShapeName;
- }
- [SerializeField]
- private List<ShapeStruct> shapes;
- [SerializeField]
- private List<Transform> targets;
- private List<BlendMesh> blends;
- private void OnEnable()
- {
- if (blends == null)
- {
- blends = new List<BlendMesh>();
- foreach (Transform target in targets)
- blends.AddRange(target.GetComponentsInChildren<BlendMesh>(true));
- }
- foreach(ShapeStruct shape in shapes)
- foreach (BlendMesh blend in blends)
- blend.SetBlendShapeWeight(shape.blendShapeType, shape.blendShapeName, 100);
- }
- }
|