UIToolkitExtensions Class

Description

Extension methods for VisualElements.

public static class UIToolkitExtensions
Inheritance
UIToolkitExtensions
Remarks

When using extension methods that modify USS properties, call them from the VisualElement's style property.

Methods

ForEachChild<TElement>(VisualElement, Action<TElement>)

Execute an action on all direct children with a certain type.

ForEachChild<TElement>(VisualElement.Hierarchy, Action<TElement>)

Execute an action on all direct children with a certain type.

GetBoundSerializedProperty(IBindable)

Tries to get the bound SerializedProperty from a bindable VisualElement through reflection.

GetChildren<TElement>(VisualElement, List<TElement>, Func<TElement, Boolean>)

Get the direct children of a VisualElement filtered by type and an optional filter delegate. It stores them in a List parameter to avoid memory allocations.

GetChildren<TElement>(VisualElement.Hierarchy, List<TElement>, Func<TElement, Boolean>)

Get the direct children of a VisualElement.Hierarchy filtered by type and an optional filter delegate. It stores them in a List parameter to avoid memory allocations.

GetFirstChild<TElement>(VisualElement, Func<TElement, Boolean>)

Get the first direct child with a certain type that passes an optional filter delegate.

GetFirstChild<TElement>(VisualElement.Hierarchy, Func<TElement, Boolean>)

Get the first direct child with a certain type that passes an optional filter delegate.

GetLabelElement(PropertyField)

Gets the main label element of a PropertyField when using a default property drawer. It should be called after the PropertyField has been processed by Unity's binding system.

GetLocalRect(VisualElement)

Get an element's layout rect in local space.

SetBorderRadius(IStyle, StyleLength, StyleLength, StyleLength, StyleLength)

Short hand for setting border radius properties in one go, like in the USS border-radius property.

SetBorderWidth(IStyle, StyleFloat, StyleFloat, StyleFloat, StyleFloat)

Short hand for setting border width properties in one go, like in the USS border-width property.

SetFlex(IStyle, StyleFloat, StyleFloat, StyleLength)

Short hand for setting flex properties in one go, like in the USS flex property.

SetMargin(IStyle, StyleLength, StyleLength, StyleLength, StyleLength)

Short hand for setting margin properties in one go, like in the USS margin property.

SetPadding(IStyle, StyleLength, StyleLength, StyleLength, StyleLength)

Short hand for setting padding properties in one go, like in the USS padding property.

SetPositionCoordinates(IStyle, StyleLength, StyleLength, StyleLength, StyleLength)

Short hand for setting a style's position coordinates.