Files
Project-M/Packages/com.rukhanka.animation/Samples~/Samples/Scenes/19. Animation and Animator Events/Scripts/DestroyVFXAfterPlay.cs
T
2026-05-31 14:27:52 -07:00

25 lines
521 B
C#

using UnityEngine;
using UnityEngine.VFX;
/////////////////////////////////////////////////////////////////////////////////
namespace Rukhanka.Samples
{
[RequireComponent(typeof(VisualEffect))]
public class DestroyVFXAfterPlay: MonoBehaviour
{
VisualEffect vfx;
void OnEnable()
{
vfx = GetComponent<VisualEffect>();
}
void Update()
{
if (vfx.aliveParticleCount == 0)
Destroy(gameObject, 1);
}
}
}