Adding the feature to sell towers with VFX and audio included
This commit is contained in:
parent
1794f65b19
commit
0b4cde4590
16 changed files with 5394 additions and 13 deletions
30
Assets/_Project/Scripts/VFX/TransientEffect.cs
Normal file
30
Assets/_Project/Scripts/VFX/TransientEffect.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Assets/_Project/Scripts/VFX/TransientEffect.cs
|
||||
using UnityEngine;
|
||||
|
||||
namespace TD.VFX
|
||||
{
|
||||
/// <summary>
|
||||
/// Destroys its GameObject a fixed time after it spawns. Drop this onto any one-shot
|
||||
/// effect prefab — a particle burst, a VFX Graph effect, a sound-only object — so it
|
||||
/// cleans itself up without any bespoke code. Designed for prefabs spawned by
|
||||
/// <see cref="SellEffectSpawner"/> (and any future effect spawner) that fire once and
|
||||
/// should disappear.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <b>Shuriken shortcut:</b> a plain <see cref="ParticleSystem"/> can instead self-destroy
|
||||
/// with no component at all — set <i>Main → Stop Action → Destroy</i> and make sure Looping
|
||||
/// is off. Use this component for <b>VFX Graph</b> effects (which have no Stop Action) or for
|
||||
/// prefabs that combine several systems and need one predictable lifetime.
|
||||
///
|
||||
/// <para>Set <see cref="lifetime"/> to comfortably exceed the effect's visible duration so it
|
||||
/// isn't cut off mid-play.</para>
|
||||
/// </remarks>
|
||||
public class TransientEffect : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Seconds after spawn before this GameObject destroys itself. Set it a little " +
|
||||
"longer than the effect's visible length so nothing is cut off.")]
|
||||
[SerializeField, Min(0f)] private float lifetime = 1.5f;
|
||||
|
||||
private void Start() => Destroy(gameObject, lifetime);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue