You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
679 B
24 lines
679 B
1 year ago
|
using UnityEngine;
|
||
|
using UnityEngine.VFX;
|
||
|
|
||
|
[ExecuteInEditMode]
|
||
|
public class MeshVFXBinder : MonoBehaviour
|
||
|
{
|
||
|
private VisualEffect vfx;
|
||
|
private MeshFilter meshFilter;
|
||
|
private Renderer render;
|
||
|
|
||
|
private static class ID
|
||
|
{
|
||
|
public static int Mesh = Shader.PropertyToID("Mesh");
|
||
|
}
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
if (vfx == null) vfx = GetComponent<VisualEffect>();
|
||
|
if (meshFilter == null) meshFilter = GetComponent<MeshFilter>();
|
||
|
if (meshFilter.sharedMesh.isReadable == false) Debug.LogError("Mesh needs to be Read/Write enabled in import options");
|
||
|
|
||
|
if (vfx.HasMesh(ID.Mesh)) vfx.SetMesh(ID.Mesh, meshFilter.sharedMesh);
|
||
|
}
|
||
|
}
|