using UnityEngine; using UnityEngine.VFX; public class DisableVFXWhenDone : MonoBehaviour { public float delay = 0.1f; private VisualEffect vfx; private float startTime; private void OnEnable() { vfx = GetComponent(); startTime = Time.realtimeSinceStartup; } private void Update() { if (Time.realtimeSinceStartup - startTime >= delay && vfx != null && !vfx.HasAnySystemAwake()) { base.gameObject.SetActive(value: false); } } }