UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Utility Systems / VFX System Completed

Utility Systems — UGTK

VFX Spawner

Summary

The VFX Spawner spawns pooled visual effects (Particle Systems and VFX Graph) through a single Play API supporting three modes: Once, SelfRestartOnEnd and IntervalSpawn. Non-looping effects auto-return to the pool, with an optional parenting policy that detaches the instance and copies the active parent's world transform.


Content


Modules Dependencies

Carried inside the prefabs. These modules are not referenced by the assembly definition - the components are simply already attached to the prefabs this module ships. Remove one of them from the project and the prefab keeps its layout and loses that behaviour, with nothing in the console to say so.

Module Component, and the prefab carrying it
UtilitySystems/PoolingSystem Mn_Pooler (in VFXSpawner)

Setup

  1. Add the VFXSpawner prefab and register your effects in it. VFXLibrary resolves them by name, so the calling code never holds a prefab reference.
  2. Choose a VFXLoopMode per effect: one that ends by itself, or one that runs until stopped.
  3. Spawn from code or from a UnityEvent. Mn_VFXAutoReturn sends the instance back to the pool when it finishes, which is what keeps a spawner from allocating a new object per hit.

Mn_VFXHierarchyDeferredRunner handles a case Unity forces on you: an effect asked for during OnDisable or while a scene is unloading cannot be parented immediately, so it is deferred to the next safe moment instead of being lost. You do not add it yourself.

An effect that never ends never returns to the pool. A looping VFXLoopMode with no stop is the usual reason a scene accumulates particle systems until the frame rate falls; if you choose looping, own the stop.


How To Use

  1. Add Mn_VFXSpawner to a GameObject and assign the pooler (Mn_Pooler) that holds the VFX prefab instances.
  2. Configure spawnAsChildOfActiveParent (keep as child vs detach + copy world TRS), respectLooping, fallbackLifetimeSeconds, spawnInterval and burstCount.
  3. Trigger effects from code with Play(VFXLoopMode.Once | SelfRestartOnEnd | IntervalSpawn, interval) or SpawnOne(), and stop with Stop() / StopAllLoopingAndDespawn().
  4. From UnityEvents/UI buttons use the parameterless wrappers: PlayOnce, PlaySelfRestartOnEnd, StartSpawningLoop, StopSpawningLoop, SpawnOneEvent, SpawnOneSelfRestartEvent, StopAllLoopingAndDespawnEvent.
  5. On spawn the spawner clears and plays every ParticleSystem and, via reflection, every VisualEffect in the instance.

Testing Scene

Open VFXSceneTest in the module's Debug/ folder.

What to do, in order:

  1. Press PlayOnce() and watch the effect return to the pool when it ends.
  2. Press PlaySelfRestartOnEnd(), then Stop().
  3. Switch to interval mode with a short interval and a burst count above one.
  4. Spawn more effects than the pool holds.

Step 4 is the one to watch: when the pool runs dry the spawner either stops silently or starts recycling effects that are still visible, and both look like a bug in the effect rather than in the pool size. Also try a looping VFX with Respect Looping off — that is how an effect ends up living forever.

VFXSceneTest: three presses of Activate, three bursts. Each instance is taken from the pool and returned by Mn_VFXAutoReturn when it finishes, so pressing repeatedly does not allocate a new object each time.


Technical Info


© 2026 Marcello De Bonis. All rights reserved

Real dependenciesOpen in the map →

Depends on 1

Used by 0

  • No other module depends on it.

Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 3 modules in total.