Version: 2023.1
LanguageEnglish
  • C#

VFXSpawnerState

class in UnityEngine.VFX

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

The spawn state of a Spawn system.

This class is useful for debugging a Visual Effect's spawner. For example, you can see if the effect is currently playing, the number of loops the spawner has processed, as well as the current state of the spawner.

To access the state of a Visual Effect's Spawn system, either use VisualEffect.GetSpawnSystemInfo or, in a class that inherits from VFXSpawnerCallbacks, override the OnUpdate method.

using UnityEngine;
using UnityEngine.VFX;

class ConstantRateEquivalent : VFXSpawnerCallbacks { public class InputProperties { [Min(0), Tooltip("Sets the number of particles to spawn per second.")] public float Rate = 10; }

static private readonly int rateID = Shader.PropertyToID("Rate");

public sealed override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { }

public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { if (state.playing) { float currentRate = vfxValues.GetFloat(rateID); state.spawnCount += currentRate * state.deltaTime; } }

public sealed override void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { } }

Properties

delayAfterLoopThe current delay time that the VFXSpawner waits for after it finishes a loop.
delayBeforeLoopThe current delay time that the VFXSpawner waits for before it starts a loop.
deltaTimeThe current delta time.
loopCountThe current loop count.
loopDurationThe duration of the looping state.
loopIndexThe current index of loop.
loopStateThe current state of VFXSpawnerState.
newLoopThis boolean indicates if a new loop has just started.
playingThe current playing state.
spawnCountThe current Spawn count.
totalTimeThe accumulated delta time since the last Play event.
vfxEventAttributeGets the modifiable current event attribute (Read Only).