VisualElement Extensions
UI Toolkit interfaces in one call chain — no separate line per property and style.
Quick start
| Before — Unity API | After — FastTools |
|---|---|
| |
Configuration methods return the original element, preserving its type. All extensions except the Editor extensions also work in a player build.
Element properties
| Unity | FastTools |
|---|---|
tooltip = "Mana cost" | SetTooltip("Mana cost") |
isDelayed = true | SetDelayed(true) |
bindItem = BindRow | SetBindItem(BindRow) |
text = "Ability Config" | SetTextSelf("Ability Config") |
SetEnabled(false) | SetEnabledSelf(false) |
The suffix Self marks a name that Unity uses, or may start to use, for a method that returns void. Such a method takes precedence over an extension, so a chain through it does not compile; the FastTools method returns the element instead.
On Unity 6000.6 and later, SetTextSelf has more overloads. They set the text through Unity's allocation-free TextElement.SetText, so text that changes every frame needs no ToString():
fps.SetTextSelf(frameCount); // int, long or ulong
speed.SetTextSelf(velocity, "0.0"); // float with an optional format
title.SetTextSelf(characters); // ReadOnlySpan<char>
log.SetTextSelf(builder); // StringBuilder
log.SetTextSelf(buffer, start, length); // a slice of a char[]
While the element is not attached to a panel, they set a string instead: it allocates, and Unity logs no warning. A bare null does not compile on 6000.6; cast it: SetTextSelf((string)null).
The full list of extensions is in the API reference.
VisualElementExtensions and INotifyValueChangedExtensions have the same names as classes of UnityEngine.UIElements. Extension calls are not affected; a call through the class name needs the namespace: Aspid.FastTools.UIElements.VisualElementExtensions.SetName(title, "Title").
Children
| Unity | FastTools |
|---|---|
Add(title) | AddChild(title) |
Insert(0, title) | InsertChild(0, title) |
Remove(title) | RemoveChild(title) |
RemoveAt(0) | RemoveChildAt(0) |
Clear() | ClearChildren() |
These methods return the parent. For multiple elements, use AddChildren, InsertChildren, RemoveChildren.
| Before — Unity API | After — FastTools |
|---|---|
| |
All of these methods have a variant with the suffix If.
Styles
Other style methods follow the same pattern. See the API reference for the full list.
Colors from strings and assets from Resources
| Before — Unity API | After — FastTools |
|---|---|
| |
| |
SetImage, SetSprite, SetVectorImage and the style sheet methods also have a …FromResources variant.
SetBackgroundImage also takes a Sprite or a VectorImage: icon.SetBackgroundImage(sprite). To clear the background, pass StyleKeyword.None; a bare null does not compile.
Bold and italic
Adding or removing one style preserves the other.
| Call | Effect |
|---|---|
AddBoldUnityFontStyleAndWeight() | Adds bold |
RemoveBoldUnityFontStyleAndWeight() | Removes bold |
AddItalicUnityFontStyleAndWeight() | Adds italic |
RemoveItalicUnityFontStyleAndWeight() | Removes italic |
SetNormalUnityFontStyleAndWeight() | Removes both styles |
The presets read the current value from the element's style, not the resolved style: a weight set in USS counts as Normal.
Custom USS properties
| Before — Unity API | After — FastTools |
|---|---|
| |
USS classes and style sheets
| Unity | FastTools |
|---|---|
AddToClassList("selected") | AddClass("selected") |
RemoveFromClassList("selected") | RemoveClass("selected") |
ToggleInClassList("selected") | ToggleClass("selected") |
EnableInClassList("selected", isFree) | EnableClass("selected", isFree) |
ClearClassList() | ClearClasses() |
styleSheets.Add(sheet) | AddStyleSheet(sheet) |
styleSheets.Insert(0, sheet) | InsertStyleSheet(0, sheet) |
styleSheets.Remove(sheet) | RemoveStyleSheet(sheet) |
styleSheets.Clear() | ClearStyleSheets() |
- Methods for several classes or style sheets take the plural name:
AddClasses("selected", "free"),AddStyleSheets(baseSheet, themeSheet). EnableClassestakes the flag first:EnableClasses(isFree, "selected", "free").EnableStyleSheet(darkSheet, isDark)adds or removes a style sheet, asEnableClassdoes for a class.
All of these methods have a variant with the suffix If. Name the arguments when a method takes two flags: EnableClassIf(condition: isEditable, "selected", enable: isFree).
Values and events
| Unity | FastTools |
|---|---|
value = 10 | SetValue(10) |
SetValueWithoutNotify(10) | SetValue(10, notify: false) |
RegisterValueChangedCallback(OnChanged) | AddValueChanged(OnChanged) |
UnregisterValueChangedCallback(OnChanged) | RemoveValueChanged(OnChanged) |
clicked += Refresh | AddClicked(Refresh) |
clicked -= Refresh | RemoveClicked(Refresh) |
For custom value types, use the generic SetValue<T, TValue>(…) and AddValueChanged<TField, TValue>(…).
For Unity.Mathematics types (float3, int2, quaternion), SetValue and AddValueChanged need no type arguments. The overloads are in the separate assembly Aspid.FastTools.VisualElements.Math (API reference), which compiles when the com.unity.mathematics package is installed, and on Unity 6000.5 and later, where Unity.Mathematics ships in the engine.
Unity's methods for event callbacks return void, so their FastTools counterparts have the suffix Self:
| Unity | FastTools |
|---|---|
RegisterCallback<ClickEvent>(OnClick) | RegisterCallbackSelf<Button, ClickEvent>(OnClick) |
RegisterCallbackOnce<ClickEvent>(OnClick) | RegisterCallbackOnceSelf<Button, ClickEvent>(OnClick) |
UnregisterCallback<ClickEvent>(OnClick) | UnregisterCallbackSelf<Button, ClickEvent>(OnClick) |
These methods take the same TrickleDown and user arguments as Unity's and return the element, so a chain continues:
var apply = new Button()
.RegisterCallbackSelf((PointerEnterEvent evt) => Hover())
.SetTooltip("Apply");
The type arguments are inferred only from a callback with a typed parameter, as above. For a method group or a lambda without parameter types, name both: RegisterCallbackSelf<Button, ClickEvent>(OnClick).
Focus
| Unity | FastTools |
|---|---|
Focus() | FocusSelf() |
Blur() | BlurSelf() |
| Before — Unity API | After — FastTools |
|---|---|
| |
IsFocused() returns false for a field inside another field (a FloatField of a Vector3Field) or in a list row. Track such a field with FocusInEvent and FocusOutEvent.
Manipulators
| Before — Unity API | After — FastTools |
|---|---|
| |
For keyboard navigation and context menus:
title.AddKeyboardNavigationManipulator(OnNavigate);
title.AddContextualMenuManipulator(BuildMenu);
The out overload lets you keep the manipulator for removal:
title.AddClickable(Refresh, out var clickable);
// Later
title.RemoveManipulatorSelf(clickable);
Editor extensions
| Before — Unity API | After — FastTools |
|---|---|
| |
| Unity | FastTools |
|---|---|
bindingPath = "_manaCost" | SetBindingPath("_manaCost") |
BindProperty(property) | BindPropertyTo(property) |
Unbind() | UnbindFrom() |
PropertyField gets SetLabel and AddValueChanged / RemoveValueChanged with a SerializedPropertyChangeEvent:
var manaCost = new PropertyField(
serializedObject.FindProperty("_manaCost"))
.SetLabel("Mana cost")
.AddValueChanged(_ => Refresh());
Open the script on double-click
AddOpenScriptCommand opens the script of a MonoBehaviour or ScriptableObject in the IDE on a left double-click; for any other object it adds nothing:
title.AddOpenScriptCommand(target);
The element's window
var window = title.GetOwnerWindow();
Returns the element’s window. If none is found, falls back to the focused window, then the window under the pointer; returns null if none is available.
The FastTools theme
rootVisualElement
.AddAspidWindowTheme()
.AddStyleSheet(catalogSheet);
The window takes the colours of the FastTools windows: the theme picked under Appearance in the FastTools settings, a theme of the project included, and the light palette on the light editor skin. A new pick recolours it at once. Colour your own style sheet with the --aspid-colors-* tokens:
.ability-sidebar {
background-color: var(--aspid-colors-surface-card);
}
Package sample
The catalog window of the EditorTools sample is built with these extensions.

