Class VelvetFilters
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Registry for user-defined UI Toolkit custom filters consumed by the filter-[name:args]
utility. Register a UnityEngine.UIElements.FilterFunctionDefinition under a name, then reference it from any
class string:
VelvetFilters.Register("dissolve", dissolveDefinition);
V.Div(className: "filter-[dissolve:0.4]");
Arguments after the name are colon-separated and fill the definition's declared parameters in
order, parsed by each slot's declared type — floats (filter-[dissolve:0.4], sign allowed)
for float slots and colors (filter-[glow:#ff0000:2]) for color slots; a missing tail is
padded from the declaration's defaults, so a bare name (filter-[dissolve]) applies the
declared defaults outright. Custom functions
compose into the same inline filter list as the built-in blur-/contrast-/…
utilities: built-ins first (canonical CSS order), then customs in class order.
Registration reaches mounted elements: registering, re-registering or unregistering a name re-resolves
every element carrying it, and an element carrying a name nothing is registered under draws no filter,
as CSS ignores a filter chain whose url() names no filter.
Not thread-safe (main thread only).
public static class VelvetFilters
- Inheritance
-
objectVelvetFilters
Methods
- Register(string, FilterFunctionDefinition?)
Registers
definitionundernameforfilter-[name:args]resolution. Re-registering a live name logs a warning and overwrites; re-registering the identical definition under the same name is a silent no-op.
- Unregister(string)
Removes a registration, after which an element carrying the name draws no filter. Returns true when the name was registered.