using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;//使用VFX接口
public class Skin2PartMesh : MonoBehaviour
{
public SkinnedMeshRenderer skinnedMesh; //蒙皮的模型动画
public VisualEffect VFXGraph; //VFX名称
public float refreshRate; //更新频率
public
// Start is called before the first frame update
void Start()
{
StartCoroutine (UpdateVFXGraph());
}
IEnumerator UpdateVFXGraph()//迭代VFX的Mesh
{
while(gameObject.activeSelf)
{
Mesh m = new Mesh();
skinnedMesh.BakeMesh(m);
Vector3[] vertices = m.vertices;
Mesh m2 = new Mesh();
m2.vertices = vertices;
VFXGraph.SetMesh("Mesh",m2);
yield return new WaitForSeconds (refreshRate);
}
}