riversong code showcase

This commit is contained in:
Daniele Marotta
2026-05-21 15:52:18 +02:00
commit 4c9eea1c02
462 changed files with 23406 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using UnityEngine;
using UnityEngine.VFX;
namespace DanieleMarotta.RiversongCodeShowcase
{
[RequireComponent(typeof(VisualEffect))]
public class AutoDestroyVfx : MonoBehaviour
{
private const float DestroyDelayWhenNoParticles = 1;
private VisualEffect _vfx;
private bool _emittedOnce;
private float _timer;
private void Awake()
{
_vfx = GetComponent<VisualEffect>();
}
private void Update()
{
if (!_vfx) return;
_emittedOnce |= _vfx.aliveParticleCount > 0;
if (!_emittedOnce) return;
if (_vfx.aliveParticleCount > 0)
{
_timer = 0;
return;
}
_timer += Time.unscaledDeltaTime;
if (_timer >= DestroyDelayWhenNoParticles) Destroy(gameObject);
}
}
}