Method Particles
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Particles(ParticleSystem?, string?, string?, string?, PlayTrigger, float, StyleOverrides?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?)
Creates a Particles element that simulates effect in a hidden,
framework-owned host and draws the live particles as textured quads inside the element —
no camera, no world-space canvas, no render-pipeline coupling. The simulation host is
instantiated on mount (its renderer disabled; only the simulation is consumed), destroyed
on unmount, and recreated when effect changes.
public static ElementNode Particles(ParticleSystem? effect, string? className = null, string? key = null, string? name = null, PlayTrigger playOn = PlayTrigger.Mount, float pixelsPerUnit = 100, StyleOverrides? styles = null, Func<VisualElement, Action>? refCallback = null, string? whileHoverClass = null, string? whileTapClass = null, string? whileFocusClass = null, IReadOnlyDictionary<string, string>? data = null, IReadOnlyDictionary<string, string>? aria = null)
Parameters
effectParticleSystemThe source ParticleSystem (typically a prefab reference) to simulate. Null mounts an inert element until an effect is supplied. Local simulation space only.
classNamestringCSS-like utility class string. Multiple classes separated by spaces.
keystringKey used to disambiguate siblings at the same position.
namestringElement name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.
playOnPlayTriggerWhen the effect starts: on mount (default) or never (manual control).
pixelsPerUnitfloatWorld-unit → element-pixel mapping for particle positions and sizes, centered on the element. Must be positive.
stylesStyleOverridesInline style overrides applied on top of USS classes.
refCallbackFunc<VisualElement, Action>Callback invoked on mount with the created VisualElement; returned Action runs on unmount.
whileHoverClassstringUSS class toggled while the pointer hovers the element (gesture-driven).
whileTapClassstringUSS class toggled while the pointer is pressed on the element (gesture-driven).
whileFocusClassstringUSS class toggled while the element holds keyboard/UI focus (gesture-driven).
dataIReadOnlyDictionary<string, string>data-* attribute map matched by
data-[...]variants.ariaIReadOnlyDictionary<string, string>aria-* attribute map matched by
aria-[...]variants.
Returns
- ElementNode
The created ElementNode representing this particles element.
Exceptions
- ArgumentOutOfRangeException
Thrown when
pixelsPerUnitis not positive.