Class VisualElementExtensions
Namespace: Aspid.FastTools.UIElements
Assembly: Aspid.FastTools.dll
Provides extension methods for VisualElement.
public static class VisualElementExtensions
Inheritance
object ← VisualElementExtensions
Methods
AddBoldUnityFontStyleAndWeight<T>(T)
Adds bold to unityFontStyleAndWeight, preserving any inline italic style.
public static T AddBoldUnityFontStyleAndWeight<T>(this T element) where T : VisualElement
Parameters
element T
The element to modify.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Transitions: Normal → Bold,
Italic → BoldAndItalic.
Other values are left unchanged.
Only the inline unityFontStyleAndWeight value is read; a bold or italic
style resolved from USS (with no inline value set) reports as Normal
and is therefore not preserved.
AddChild<T>(T, VisualElement?)
Adds an element to the contentContainer of this element.
public static T AddChild<T>(this T element, VisualElement? child) where T : VisualElement
Parameters
element T
The element to modify.
child VisualElement?
The child element to add; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildIf<T>(T, bool, VisualElement?)
Conditionally adds an element to the contentContainer of this element.
public static T AddChildIf<T>(this T element, bool condition, VisualElement? child) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
child VisualElement?
The child element to add; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildren<T>(T, params VisualElement?[]?)
Adds an array of child elements to the contentContainer of this element.
public static T AddChildren<T>(this T element, params VisualElement?[]? children) where T : VisualElement
Parameters
element T
The element to modify.
children VisualElement?[]?
The children to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildren<T>(T, List<VisualElement>?)
Adds a list of child elements to the contentContainer of this element.
public static T AddChildren<T>(this T element, List<VisualElement>? children) where T : VisualElement
Parameters
element T
The element to modify.
children List<VisualElement>?
The children to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildren<T>(T, IEnumerable<VisualElement?>?)
Adds an enumerable of child elements to the contentContainer of this element.
public static T AddChildren<T>(this T element, IEnumerable<VisualElement?>? children) where T : VisualElement
Parameters
element T
The element to modify.
children IEnumerable<VisualElement?>?
The children to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
children is copied before the first change, so it may be the live
Children of this or another element.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildren<T>(T, ReadOnlySpan<VisualElement>)
Adds a read-only span of child elements to the contentContainer of this element.
public static T AddChildren<T>(this T element, ReadOnlySpan<VisualElement> children) where T : VisualElement
Parameters
element T
The element to modify.
children ReadOnlySpan<VisualElement>
The children to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildrenIf<T>(T, bool, params VisualElement?[]?)
Conditionally adds an array of child elements to the contentContainer of this element.
public static T AddChildrenIf<T>(this T element, bool condition, params VisualElement?[]? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
children VisualElement?[]?
The children to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildrenIf<T>(T, bool, List<VisualElement>?)
Conditionally adds a list of child elements to the contentContainer of this element.
public static T AddChildrenIf<T>(this T element, bool condition, List<VisualElement>? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
children List<VisualElement>?
The children to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildrenIf<T>(T, bool, IEnumerable<VisualElement?>?)
Conditionally adds an enumerable of child elements to the contentContainer of this element.
public static T AddChildrenIf<T>(this T element, bool condition, IEnumerable<VisualElement?>? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
children IEnumerable<VisualElement?>?
The children to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
children is copied before the first change, so it may be the live
Children of this or another element.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddChildrenIf<T>(T, bool, ReadOnlySpan<VisualElement>)
Conditionally adds a read-only span of child elements to the contentContainer of this element.
public static T AddChildrenIf<T>(this T element, bool condition, ReadOnlySpan<VisualElement> children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
children ReadOnlySpan<VisualElement>
The children to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Exceptions
A non-null child is added to an element without a contentContainer, such as a ListView or a TreeView.
AddClass<T>(T, string?)
Adds a USS class to the element.
public static T AddClass<T>(this T element, string? className) where T : VisualElement
Parameters
element T
The element to modify.
className string?
The USS class name to add; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddClassIf<T>(T, bool, string?)
Conditionally adds a USS class to the element.
public static T AddClassIf<T>(this T element, bool condition, string? className) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
className string?
The USS class name to add; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddClasses<T>(T, params string?[]?)
Adds an array of USS classes to the element.
public static T AddClasses<T>(this T element, params string?[]? classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames string?[]?
The USS class names to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddClasses<T>(T, List<string>?)
Adds a list of USS classes to the element.
public static T AddClasses<T>(this T element, List<string>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
The USS class names to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddClasses<T>(T, IEnumerable<string?>?)
Adds an enumerable of USS classes to the element.
public static T AddClasses<T>(this T element, IEnumerable<string?>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames IEnumerable<string?>?
The USS class names to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
classNames is copied before the first change, so it may read
GetClasses of this element, directly or through a LINQ query.
AddClasses<T>(T, ReadOnlySpan<string>)
Adds a read-only span of USS classes to the element.
public static T AddClasses<T>(this T element, ReadOnlySpan<string> classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames ReadOnlySpan<string>
The USS class names to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddClassesIf<T>(T, bool, params string?[]?)
Conditionally adds an array of USS classes to the element.
public static T AddClassesIf<T>(this T element, bool condition, params string?[]? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames string?[]?
The USS class names to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddClassesIf<T>(T, bool, List<string>?)
Conditionally adds a list of USS classes to the element.
public static T AddClassesIf<T>(this T element, bool condition, List<string>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
The USS class names to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddClassesIf<T>(T, bool, IEnumerable<string?>?)
Conditionally adds an enumerable of USS classes to the element.
public static T AddClassesIf<T>(this T element, bool condition, IEnumerable<string?>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames IEnumerable<string?>?
The USS class names to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
classNames is copied before the first change, so it may read
GetClasses of this element, directly or through a LINQ query.
AddClassesIf<T>(T, bool, ReadOnlySpan<string>)
Conditionally adds a read-only span of USS classes to the element.
public static T AddClassesIf<T>(this T element, bool condition, ReadOnlySpan<string> classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames ReadOnlySpan<string>
The USS class names to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddItalicUnityFontStyleAndWeight<T>(T)
Adds italic to unityFontStyleAndWeight, preserving any inline bold style.
public static T AddItalicUnityFontStyleAndWeight<T>(this T element) where T : VisualElement
Parameters
element T
The element to modify.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Transitions: Normal → Italic,
Bold → BoldAndItalic.
Other values are left unchanged.
Only the inline unityFontStyleAndWeight value is read; a bold or italic
style resolved from USS (with no inline value set) reports as Normal
and is therefore not preserved.
AddStyleSheet<T>(T, StyleSheet?)
Adds a style sheet to styleSheets.
public static T AddStyleSheet<T>(this T element, StyleSheet? styleSheet) where T : VisualElement
Parameters
element T
The element to modify.
styleSheet StyleSheet?
The style sheet to add; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheetFromResources<T>(T, string)
Loads a StyleSheet from Resources and adds it to styleSheets.
public static T AddStyleSheetFromResources<T>(this T element, string path) where T : VisualElement
Parameters
element T
The element to modify.
path string
The Resources-relative path to the style sheet asset.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
AddStyleSheetFromResourcesIf<T>(T, bool, string)
Conditionally loads a StyleSheet from Resources and adds it to styleSheets.
public static T AddStyleSheetFromResourcesIf<T>(this T element, bool condition, string path) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
path string
The Resources-relative path to the style sheet asset.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
AddStyleSheetIf<T>(T, bool, StyleSheet?)
Conditionally adds a style sheet to styleSheets.
public static T AddStyleSheetIf<T>(this T element, bool condition, StyleSheet? styleSheet) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheet StyleSheet?
The style sheet to add; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheets<T>(T, params StyleSheet?[]?)
Adds an array of style sheets to styleSheets.
public static T AddStyleSheets<T>(this T element, params StyleSheet?[]? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
styleSheets StyleSheet?[]?
The style sheets to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheets<T>(T, List<StyleSheet>?)
Adds a list of style sheets to styleSheets.
public static T AddStyleSheets<T>(this T element, List<StyleSheet>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
styleSheets List<StyleSheet>?
The style sheets to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheets<T>(T, IEnumerable<StyleSheet?>?)
Adds an enumerable of style sheets to styleSheets.
public static T AddStyleSheets<T>(this T element, IEnumerable<StyleSheet?>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
styleSheets IEnumerable<StyleSheet?>?
The style sheets to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheets<T>(T, ReadOnlySpan<StyleSheet>)
Adds a read-only span of style sheets to styleSheets.
public static T AddStyleSheets<T>(this T element, ReadOnlySpan<StyleSheet> styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
styleSheets ReadOnlySpan<StyleSheet>
The style sheets to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheetsFromResources<T>(T, params string[]?)
Loads style sheets from an array of Resources paths and adds them to styleSheets.
public static T AddStyleSheetsFromResources<T>(this T element, params string[]? paths) where T : VisualElement
Parameters
element T
The element to modify.
paths string[]?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
AddStyleSheetsFromResources<T>(T, List<string>?)
Loads style sheets from a list of Resources paths and adds them to styleSheets.
public static T AddStyleSheetsFromResources<T>(this T element, List<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
AddStyleSheetsFromResources<T>(T, IEnumerable<string>?)
Loads style sheets from an enumerable of Resources paths and adds them to styleSheets.
public static T AddStyleSheetsFromResources<T>(this T element, IEnumerable<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
paths IEnumerable<string>?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
AddStyleSheetsFromResources<T>(T, ReadOnlySpan<string>)
Loads style sheets from a read-only span of Resources paths and adds them to styleSheets.
public static T AddStyleSheetsFromResources<T>(this T element, ReadOnlySpan<string> paths) where T : VisualElement
Parameters
element T
The element to modify.
paths ReadOnlySpan<string>
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
AddStyleSheetsFromResourcesIf<T>(T, bool, params string[]?)
Conditionally loads style sheets from an array of Resources paths and adds them to styleSheets.
public static T AddStyleSheetsFromResourcesIf<T>(this T element, bool condition, params string[]? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
paths string[]?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
AddStyleSheetsFromResourcesIf<T>(T, bool, List<string>?)
Conditionally loads style sheets from a list of Resources paths and adds them to styleSheets.
public static T AddStyleSheetsFromResourcesIf<T>(this T element, bool condition, List<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
AddStyleSheetsFromResourcesIf<T>(T, bool, IEnumerable<string>?)
Conditionally loads style sheets from an enumerable of Resources paths and adds them to styleSheets.
public static T AddStyleSheetsFromResourcesIf<T>(this T element, bool condition, IEnumerable<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
paths IEnumerable<string>?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
AddStyleSheetsFromResourcesIf<T>(T, bool, ReadOnlySpan<string>)
Conditionally loads style sheets from a read-only span of Resources paths and adds them to styleSheets.
public static T AddStyleSheetsFromResourcesIf<T>(this T element, bool condition, ReadOnlySpan<string> paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
paths ReadOnlySpan<string>
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
AddStyleSheetsIf<T>(T, bool, params StyleSheet?[]?)
Conditionally adds an array of style sheets to styleSheets.
public static T AddStyleSheetsIf<T>(this T element, bool condition, params StyleSheet?[]? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheets StyleSheet?[]?
The style sheets to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheetsIf<T>(T, bool, List<StyleSheet>?)
Conditionally adds a list of style sheets to styleSheets.
public static T AddStyleSheetsIf<T>(this T element, bool condition, List<StyleSheet>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheets List<StyleSheet>?
The style sheets to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheetsIf<T>(T, bool, IEnumerable<StyleSheet?>?)
Conditionally adds an enumerable of style sheets to styleSheets.
public static T AddStyleSheetsIf<T>(this T element, bool condition, IEnumerable<StyleSheet?>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheets IEnumerable<StyleSheet?>?
The style sheets to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
AddStyleSheetsIf<T>(T, bool, ReadOnlySpan<StyleSheet>)
Conditionally adds a read-only span of style sheets to styleSheets.
public static T AddStyleSheetsIf<T>(this T element, bool condition, ReadOnlySpan<StyleSheet> styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheets ReadOnlySpan<StyleSheet>
The style sheets to add; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ClearChildren<T>(T)
Removes all children from the element.
public static T ClearChildren<T>(this T element) where T : VisualElement
Parameters
element T
The element to modify.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
ClearChildrenIf<T>(T, bool)
Conditionally removes all children from the element.
public static T ClearChildrenIf<T>(this T element, bool condition) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
ClearClasses<T>(T)
Removes all USS classes from the element.
public static T ClearClasses<T>(this T element) where T : VisualElement
Parameters
element T
The element to modify.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ClearClassesIf<T>(T, bool)
Conditionally removes all USS classes from the element.
public static T ClearClassesIf<T>(this T element, bool condition) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ClearStyleSheets<T>(T)
Removes all style sheets from styleSheets.
public static T ClearStyleSheets<T>(this T element) where T : VisualElement
Parameters
element T
The element to modify.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ClearStyleSheetsIf<T>(T, bool)
Conditionally removes all style sheets from styleSheets.
public static T ClearStyleSheetsIf<T>(this T element, bool condition) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableClass<T>(T, string?, bool)
Adds or removes the USS class depending on enable.
public static T EnableClass<T>(this T element, string? className, bool enable) where T : VisualElement
Parameters
element T
The element to modify.
className string?
The USS class name to enable or disable; null leaves the element unchanged.
enable bool
When true, the class is added; otherwise, it is removed.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableClassIf<T>(T, bool, string?, bool)
Conditionally adds or removes the USS class depending on enable.
public static T EnableClassIf<T>(this T element, bool condition, string? className, bool enable) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
className string?
The USS class name to enable or disable; null leaves the element unchanged.
enable bool
When true, the class is added; otherwise, it is removed.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableClasses<T>(T, bool, params string?[]?)
Adds or removes an array of USS classes depending on enable.
public static T EnableClasses<T>(this T element, bool enable, params string?[]? classNames) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the classes are added; otherwise, they are removed.
classNames string?[]?
The USS class names to enable or disable; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableClasses<T>(T, bool, List<string>?)
Adds or removes a list of USS classes depending on enable.
public static T EnableClasses<T>(this T element, bool enable, List<string>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the classes are added; otherwise, they are removed.
The USS class names to enable or disable; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableClasses<T>(T, bool, IEnumerable<string?>?)
Adds or removes an enumerable of USS classes depending on enable.
public static T EnableClasses<T>(this T element, bool enable, IEnumerable<string?>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the classes are added; otherwise, they are removed.
classNames IEnumerable<string?>?
The USS class names to enable or disable; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
classNames is copied before the first change, so it may read
GetClasses of this element, directly or through a LINQ query.
EnableClasses<T>(T, bool, ReadOnlySpan<string>)
Adds or removes a read-only span of USS classes depending on enable.
public static T EnableClasses<T>(this T element, bool enable, ReadOnlySpan<string> classNames) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the classes are added; otherwise, they are removed.
classNames ReadOnlySpan<string>
The USS class names to enable or disable; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableClassesIf<T>(T, bool, bool, params string?[]?)
Conditionally adds or removes an array of USS classes depending on enable.
public static T EnableClassesIf<T>(this T element, bool condition, bool enable, params string?[]? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the classes are added; otherwise, they are removed.
classNames string?[]?
The USS class names to enable or disable; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableClassesIf<T>(T, bool, bool, List<string>?)
Conditionally adds or removes a list of USS classes depending on enable.
public static T EnableClassesIf<T>(this T element, bool condition, bool enable, List<string>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the classes are added; otherwise, they are removed.
The USS class names to enable or disable; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableClassesIf<T>(T, bool, bool, IEnumerable<string?>?)
Conditionally adds or removes an enumerable of USS classes depending on enable.
public static T EnableClassesIf<T>(this T element, bool condition, bool enable, IEnumerable<string?>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the classes are added; otherwise, they are removed.
classNames IEnumerable<string?>?
The USS class names to enable or disable; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
classNames is copied before the first change, so it may read
GetClasses of this element, directly or through a LINQ query.
EnableClassesIf<T>(T, bool, bool, ReadOnlySpan<string>)
Conditionally adds or removes a read-only span of USS classes depending on enable.
public static T EnableClassesIf<T>(this T element, bool condition, bool enable, ReadOnlySpan<string> classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the classes are added; otherwise, they are removed.
classNames ReadOnlySpan<string>
The USS class names to enable or disable; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheet<T>(T, StyleSheet?, bool)
Adds a style sheet to styleSheets or removes it, depending on enable.
public static T EnableStyleSheet<T>(this T element, StyleSheet? styleSheet, bool enable) where T : VisualElement
Parameters
element T
The element to modify.
styleSheet StyleSheet?
The style sheet to add or remove; null leaves the element unchanged.
enable bool
When true, the style sheet is added; otherwise, it is removed.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheetFromResources<T>(T, string, bool)
Loads a StyleSheet from Resources and adds it to styleSheets or removes it, depending on enable.
public static T EnableStyleSheetFromResources<T>(this T element, string path, bool enable) where T : VisualElement
Parameters
element T
The element to modify.
path string
The Resources-relative path to the style sheet asset.
enable bool
When true, the style sheet is added; otherwise, it is removed.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
EnableStyleSheetFromResourcesIf<T>(T, bool, string, bool)
Conditionally loads a StyleSheet from Resources and adds it to styleSheets or removes it, depending on enable.
public static T EnableStyleSheetFromResourcesIf<T>(this T element, bool condition, string path, bool enable) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
path string
The Resources-relative path to the style sheet asset.
enable bool
When true, the style sheet is added; otherwise, it is removed.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
EnableStyleSheetIf<T>(T, bool, StyleSheet?, bool)
Conditionally adds a style sheet to styleSheets or removes it, depending on enable.
public static T EnableStyleSheetIf<T>(this T element, bool condition, StyleSheet? styleSheet, bool enable) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheet StyleSheet?
The style sheet to add or remove; null leaves the element unchanged.
enable bool
When true, the style sheet is added; otherwise, it is removed.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheets<T>(T, bool, params StyleSheet?[]?)
Adds an array of style sheets to styleSheets or removes them, depending on enable.
public static T EnableStyleSheets<T>(this T element, bool enable, params StyleSheet?[]? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the style sheets are added; otherwise, they are removed.
styleSheets StyleSheet?[]?
The style sheets to add or remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheets<T>(T, bool, List<StyleSheet>?)
Adds a list of style sheets to styleSheets or removes them, depending on enable.
public static T EnableStyleSheets<T>(this T element, bool enable, List<StyleSheet>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the style sheets are added; otherwise, they are removed.
styleSheets List<StyleSheet>?
The style sheets to add or remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheets<T>(T, bool, IEnumerable<StyleSheet?>?)
Adds an enumerable of style sheets to styleSheets or removes them, depending on enable.
public static T EnableStyleSheets<T>(this T element, bool enable, IEnumerable<StyleSheet?>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the style sheets are added; otherwise, they are removed.
styleSheets IEnumerable<StyleSheet?>?
The style sheets to add or remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheets<T>(T, bool, ReadOnlySpan<StyleSheet>)
Adds a read-only span of style sheets to styleSheets or removes them, depending on enable.
public static T EnableStyleSheets<T>(this T element, bool enable, ReadOnlySpan<StyleSheet> styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the style sheets are added; otherwise, they are removed.
styleSheets ReadOnlySpan<StyleSheet>
The style sheets to add or remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheetsFromResources<T>(T, bool, params string[]?)
Loads style sheets from an array of Resources paths and adds them to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsFromResources<T>(this T element, bool enable, params string[]? paths) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the style sheets are added; otherwise, they are removed.
paths string[]?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
EnableStyleSheetsFromResources<T>(T, bool, List<string>?)
Loads style sheets from a list of Resources paths and adds them to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsFromResources<T>(this T element, bool enable, List<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the style sheets are added; otherwise, they are removed.
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
EnableStyleSheetsFromResources<T>(T, bool, IEnumerable<string>?)
Loads style sheets from an enumerable of Resources paths and adds them to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsFromResources<T>(this T element, bool enable, IEnumerable<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the style sheets are added; otherwise, they are removed.
paths IEnumerable<string>?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
EnableStyleSheetsFromResources<T>(T, bool, ReadOnlySpan<string>)
Loads style sheets from a read-only span of Resources paths and adds them to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsFromResources<T>(this T element, bool enable, ReadOnlySpan<string> paths) where T : VisualElement
Parameters
element T
The element to modify.
enable bool
When true, the style sheets are added; otherwise, they are removed.
paths ReadOnlySpan<string>
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
EnableStyleSheetsFromResourcesIf<T>(T, bool, bool, params string[]?)
Conditionally loads style sheets from an array of Resources paths and adds them to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsFromResourcesIf<T>(this T element, bool condition, bool enable, params string[]? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the style sheets are added; otherwise, they are removed.
paths string[]?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
EnableStyleSheetsFromResourcesIf<T>(T, bool, bool, List<string>?)
Conditionally loads style sheets from a list of Resources paths and adds them to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsFromResourcesIf<T>(this T element, bool condition, bool enable, List<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the style sheets are added; otherwise, they are removed.
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
EnableStyleSheetsFromResourcesIf<T>(T, bool, bool, IEnumerable<string>?)
Conditionally loads style sheets from an enumerable of Resources paths and adds them to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsFromResourcesIf<T>(this T element, bool condition, bool enable, IEnumerable<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the style sheets are added; otherwise, they are removed.
paths IEnumerable<string>?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
EnableStyleSheetsFromResourcesIf<T>(T, bool, bool, ReadOnlySpan<string>)
Conditionally loads style sheets from a read-only span of Resources paths and adds them to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsFromResourcesIf<T>(this T element, bool condition, bool enable, ReadOnlySpan<string> paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the style sheets are added; otherwise, they are removed.
paths ReadOnlySpan<string>
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
EnableStyleSheetsIf<T>(T, bool, bool, params StyleSheet?[]?)
Conditionally adds an array of style sheets to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsIf<T>(this T element, bool condition, bool enable, params StyleSheet?[]? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the style sheets are added; otherwise, they are removed.
styleSheets StyleSheet?[]?
The style sheets to add or remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheetsIf<T>(T, bool, bool, List<StyleSheet>?)
Conditionally adds a list of style sheets to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsIf<T>(this T element, bool condition, bool enable, List<StyleSheet>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the style sheets are added; otherwise, they are removed.
styleSheets List<StyleSheet>?
The style sheets to add or remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheetsIf<T>(T, bool, bool, IEnumerable<StyleSheet?>?)
Conditionally adds an enumerable of style sheets to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsIf<T>(this T element, bool condition, bool enable, IEnumerable<StyleSheet?>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the style sheets are added; otherwise, they are removed.
styleSheets IEnumerable<StyleSheet?>?
The style sheets to add or remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
EnableStyleSheetsIf<T>(T, bool, bool, ReadOnlySpan<StyleSheet>)
Conditionally adds a read-only span of style sheets to styleSheets or removes them, depending on enable.
public static T EnableStyleSheetsIf<T>(this T element, bool condition, bool enable, ReadOnlySpan<StyleSheet> styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
enable bool
When true, the style sheets are added; otherwise, they are removed.
styleSheets ReadOnlySpan<StyleSheet>
The style sheets to add or remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
InsertChild<T>(T, int, VisualElement?)
Inserts a child element at the specified index in the contentContainer of this element.
public static T InsertChild<T>(this T element, int index, VisualElement? child) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to insert the child.
child VisualElement?
The child element to insert; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildIf<T>(T, bool, int, VisualElement?)
Conditionally inserts a child element at the specified index in the contentContainer of this element.
public static T InsertChildIf<T>(this T element, bool condition, int index, VisualElement? child) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to insert the child.
child VisualElement?
The child element to insert; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildren<T>(T, int, params VisualElement?[]?)
Inserts an array of child elements starting at the specified index in the contentContainer of this element.
public static T InsertChildren<T>(this T element, int index, params VisualElement?[]? children) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting children.
children VisualElement?[]?
The children to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildren<T>(T, int, List<VisualElement>?)
Inserts a list of child elements starting at the specified index in the contentContainer of this element.
public static T InsertChildren<T>(this T element, int index, List<VisualElement>? children) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting children.
children List<VisualElement>?
The children to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildren<T>(T, int, IEnumerable<VisualElement?>?)
Inserts an enumerable of child elements starting at the specified index in the contentContainer of this element.
public static T InsertChildren<T>(this T element, int index, IEnumerable<VisualElement?>? children) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting children.
children IEnumerable<VisualElement?>?
The children to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
children is copied before the first change, so it may be the live Children of another element.
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildren<T>(T, int, ReadOnlySpan<VisualElement>)
Inserts a read-only span of child elements starting at the specified index in the contentContainer of this element.
public static T InsertChildren<T>(this T element, int index, ReadOnlySpan<VisualElement> children) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting children.
children ReadOnlySpan<VisualElement>
The children to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildrenIf<T>(T, bool, int, params VisualElement?[]?)
Conditionally inserts an array of child elements starting at the specified index in the contentContainer of this element.
public static T InsertChildrenIf<T>(this T element, bool condition, int index, params VisualElement?[]? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting children.
children VisualElement?[]?
The children to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildrenIf<T>(T, bool, int, List<VisualElement>?)
Conditionally inserts a list of child elements starting at the specified index in the contentContainer of this element.
public static T InsertChildrenIf<T>(this T element, bool condition, int index, List<VisualElement>? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting children.
children List<VisualElement>?
The children to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildrenIf<T>(T, bool, int, IEnumerable<VisualElement?>?)
Conditionally inserts an enumerable of child elements starting at the specified index in the contentContainer of this element.
public static T InsertChildrenIf<T>(this T element, bool condition, int index, IEnumerable<VisualElement?>? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting children.
children IEnumerable<VisualElement?>?
The children to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
children is copied before the first change, so it may be the live Children of another element.
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertChildrenIf<T>(T, bool, int, ReadOnlySpan<VisualElement>)
Conditionally inserts a read-only span of child elements starting at the specified index in the contentContainer of this element.
public static T InsertChildrenIf<T>(this T element, bool condition, int index, ReadOnlySpan<VisualElement> children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting children.
children ReadOnlySpan<VisualElement>
The children to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
InsertStyleSheet<T>(T, int, StyleSheet?)
Inserts a style sheet into styleSheets at the specified index.
public static T InsertStyleSheet<T>(this T element, int index, StyleSheet? styleSheet) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to insert the style sheet.
styleSheet StyleSheet?
The style sheet to insert; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
A style sheet that styleSheets already holds keeps its position.
InsertStyleSheetFromResources<T>(T, int, string)
Loads a StyleSheet from Resources and inserts it into styleSheets at the specified index.
public static T InsertStyleSheetFromResources<T>(this T element, int index, string path) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to insert the style sheet.
path string
The Resources-relative path to the style sheet asset.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
A style sheet that styleSheets already holds keeps its position.
InsertStyleSheetFromResourcesIf<T>(T, bool, int, string)
Conditionally loads a StyleSheet from Resources and inserts it into styleSheets at the specified index.
public static T InsertStyleSheetFromResourcesIf<T>(this T element, bool condition, int index, string path) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to insert the style sheet.
path string
The Resources-relative path to the style sheet asset.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
A style sheet that styleSheets already holds keeps its position.
InsertStyleSheetIf<T>(T, bool, int, StyleSheet?)
Conditionally inserts a style sheet into styleSheets at the specified index.
public static T InsertStyleSheetIf<T>(this T element, bool condition, int index, StyleSheet? styleSheet) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to insert the style sheet.
styleSheet StyleSheet?
The style sheet to insert; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
A style sheet that styleSheets already holds keeps its position.
InsertStyleSheets<T>(T, int, params StyleSheet?[]?)
Inserts an array of style sheets into styleSheets starting at the specified index.
public static T InsertStyleSheets<T>(this T element, int index, params StyleSheet?[]? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting style sheets.
styleSheets StyleSheet?[]?
The style sheets to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheets<T>(T, int, List<StyleSheet>?)
Inserts a list of style sheets into styleSheets starting at the specified index.
public static T InsertStyleSheets<T>(this T element, int index, List<StyleSheet>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting style sheets.
styleSheets List<StyleSheet>?
The style sheets to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheets<T>(T, int, IEnumerable<StyleSheet?>?)
Inserts an enumerable of style sheets into styleSheets starting at the specified index.
public static T InsertStyleSheets<T>(this T element, int index, IEnumerable<StyleSheet?>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting style sheets.
styleSheets IEnumerable<StyleSheet?>?
The style sheets to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheets<T>(T, int, ReadOnlySpan<StyleSheet>)
Inserts a read-only span of style sheets into styleSheets starting at the specified index.
public static T InsertStyleSheets<T>(this T element, int index, ReadOnlySpan<StyleSheet> styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting style sheets.
styleSheets ReadOnlySpan<StyleSheet>
The style sheets to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsFromResources<T>(T, int, params string[]?)
Loads style sheets from an array of Resources paths and inserts them into styleSheets starting at the specified index.
public static T InsertStyleSheetsFromResources<T>(this T element, int index, params string[]? paths) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting style sheets.
paths string[]?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsFromResources<T>(T, int, List<string>?)
Loads style sheets from a list of Resources paths and inserts them into styleSheets starting at the specified index.
public static T InsertStyleSheetsFromResources<T>(this T element, int index, List<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting style sheets.
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsFromResources<T>(T, int, IEnumerable<string>?)
Loads style sheets from an enumerable of Resources paths and inserts them into styleSheets starting at the specified index.
public static T InsertStyleSheetsFromResources<T>(this T element, int index, IEnumerable<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting style sheets.
paths IEnumerable<string>?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsFromResources<T>(T, int, ReadOnlySpan<string>)
Loads style sheets from a read-only span of Resources paths and inserts them into styleSheets starting at the specified index.
public static T InsertStyleSheetsFromResources<T>(this T element, int index, ReadOnlySpan<string> paths) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index at which to start inserting style sheets.
paths ReadOnlySpan<string>
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsFromResourcesIf<T>(T, bool, int, params string[]?)
Conditionally loads style sheets from an array of Resources paths and inserts them into styleSheets starting at the specified index.
public static T InsertStyleSheetsFromResourcesIf<T>(this T element, bool condition, int index, params string[]? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting style sheets.
paths string[]?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsFromResourcesIf<T>(T, bool, int, List<string>?)
Conditionally loads style sheets from a list of Resources paths and inserts them into styleSheets starting at the specified index.
public static T InsertStyleSheetsFromResourcesIf<T>(this T element, bool condition, int index, List<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting style sheets.
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsFromResourcesIf<T>(T, bool, int, IEnumerable<string>?)
Conditionally loads style sheets from an enumerable of Resources paths and inserts them into styleSheets starting at the specified index.
public static T InsertStyleSheetsFromResourcesIf<T>(this T element, bool condition, int index, IEnumerable<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting style sheets.
paths IEnumerable<string>?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsFromResourcesIf<T>(T, bool, int, ReadOnlySpan<string>)
Conditionally loads style sheets from a read-only span of Resources paths and inserts them into styleSheets starting at the specified index.
public static T InsertStyleSheetsFromResourcesIf<T>(this T element, bool condition, int index, ReadOnlySpan<string> paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting style sheets.
paths ReadOnlySpan<string>
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsIf<T>(T, bool, int, params StyleSheet?[]?)
Conditionally inserts an array of style sheets into styleSheets starting at the specified index.
public static T InsertStyleSheetsIf<T>(this T element, bool condition, int index, params StyleSheet?[]? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting style sheets.
styleSheets StyleSheet?[]?
The style sheets to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsIf<T>(T, bool, int, List<StyleSheet>?)
Conditionally inserts a list of style sheets into styleSheets starting at the specified index.
public static T InsertStyleSheetsIf<T>(this T element, bool condition, int index, List<StyleSheet>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting style sheets.
styleSheets List<StyleSheet>?
The style sheets to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsIf<T>(T, bool, int, IEnumerable<StyleSheet?>?)
Conditionally inserts an enumerable of style sheets into styleSheets starting at the specified index.
public static T InsertStyleSheetsIf<T>(this T element, bool condition, int index, IEnumerable<StyleSheet?>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting style sheets.
styleSheets IEnumerable<StyleSheet?>?
The style sheets to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
InsertStyleSheetsIf<T>(T, bool, int, ReadOnlySpan<StyleSheet>)
Conditionally inserts a read-only span of style sheets into styleSheets starting at the specified index.
public static T InsertStyleSheetsIf<T>(this T element, bool condition, int index, ReadOnlySpan<StyleSheet> styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index at which to start inserting style sheets.
styleSheets ReadOnlySpan<StyleSheet>
The style sheets to insert; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Style sheets are inserted in order; a style sheet that styleSheets already holds keeps its position.
RemoveBoldUnityFontStyleAndWeight<T>(T)
Removes bold from unityFontStyleAndWeight, preserving any inline italic style.
public static T RemoveBoldUnityFontStyleAndWeight<T>(this T element) where T : VisualElement
Parameters
element T
The element to modify.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Transitions: Bold → Normal,
BoldAndItalic → Italic.
Other values are left unchanged.
Only the inline unityFontStyleAndWeight value is read; a bold or italic
style resolved from USS (with no inline value set) reports as Normal,
so nothing is written and the USS style stays, including the bold it was meant to remove.
RemoveChild<T>(T, VisualElement?)
Removes the specified child from the element.
public static T RemoveChild<T>(this T element, VisualElement? child) where T : VisualElement
Parameters
element T
The element to modify.
child VisualElement?
The child element to remove; null or an element that is not a child leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveChildAt<T>(T, int)
Removes the child at the specified index from the element.
public static T RemoveChildAt<T>(this T element, int index) where T : VisualElement
Parameters
element T
The element to modify.
index int
The index of the child to remove.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
RemoveChildAtIf<T>(T, bool, int)
Conditionally removes the child at the specified index from the element.
public static T RemoveChildAtIf<T>(this T element, bool condition, int index) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
index int
The index of the child to remove.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Does nothing on an element without a contentContainer, such as a ListView or a TreeView.
RemoveChildIf<T>(T, bool, VisualElement?)
Conditionally removes the specified child from the element.
public static T RemoveChildIf<T>(this T element, bool condition, VisualElement? child) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
child VisualElement?
The child element to remove; null or an element that is not a child leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveChildren<T>(T, params VisualElement?[]?)
Removes an array of child elements from the element.
public static T RemoveChildren<T>(this T element, params VisualElement?[]? children) where T : VisualElement
Parameters
element T
The element to modify.
children VisualElement?[]?
The children to remove; null entries and elements that are not children are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveChildren<T>(T, List<VisualElement>?)
Removes a list of child elements from the element.
public static T RemoveChildren<T>(this T element, List<VisualElement>? children) where T : VisualElement
Parameters
element T
The element to modify.
children List<VisualElement>?
The children to remove; null entries and elements that are not children are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveChildren<T>(T, IEnumerable<VisualElement?>?)
Removes an enumerable of child elements from the element.
public static T RemoveChildren<T>(this T element, IEnumerable<VisualElement?>? children) where T : VisualElement
Parameters
element T
The element to modify.
children IEnumerable<VisualElement?>?
The children to remove; null entries and elements that are not children are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
children is copied before the first change, so it may be this element's own
Children.
RemoveChildren<T>(T, ReadOnlySpan<VisualElement>)
Removes a read-only span of child elements from the element.
public static T RemoveChildren<T>(this T element, ReadOnlySpan<VisualElement> children) where T : VisualElement
Parameters
element T
The element to modify.
children ReadOnlySpan<VisualElement>
The children to remove; null entries and elements that are not children are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveChildrenIf<T>(T, bool, params VisualElement?[]?)
Conditionally removes an array of child elements from the element.
public static T RemoveChildrenIf<T>(this T element, bool condition, params VisualElement?[]? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
children VisualElement?[]?
The children to remove; null entries and elements that are not children are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveChildrenIf<T>(T, bool, List<VisualElement>?)
Conditionally removes a list of child elements from the element.
public static T RemoveChildrenIf<T>(this T element, bool condition, List<VisualElement>? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
children List<VisualElement>?
The children to remove; null entries and elements that are not children are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveChildrenIf<T>(T, bool, IEnumerable<VisualElement?>?)
Conditionally removes an enumerable of child elements from the element.
public static T RemoveChildrenIf<T>(this T element, bool condition, IEnumerable<VisualElement?>? children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
children IEnumerable<VisualElement?>?
The children to remove; null entries and elements that are not children are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
children is copied before the first change, so it may be this element's own
Children.
RemoveChildrenIf<T>(T, bool, ReadOnlySpan<VisualElement>)
Conditionally removes a read-only span of child elements from the element.
public static T RemoveChildrenIf<T>(this T element, bool condition, ReadOnlySpan<VisualElement> children) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
children ReadOnlySpan<VisualElement>
The children to remove; null entries and elements that are not children are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveClass<T>(T, string?)
Removes a USS class from the element.
public static T RemoveClass<T>(this T element, string? className) where T : VisualElement
Parameters
element T
The element to modify.
className string?
The USS class name to remove; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveClassIf<T>(T, bool, string?)
Conditionally removes a USS class from the element.
public static T RemoveClassIf<T>(this T element, bool condition, string? className) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
className string?
The USS class name to remove; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveClasses<T>(T, params string?[]?)
Removes an array of USS classes from the element.
public static T RemoveClasses<T>(this T element, params string?[]? classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames string?[]?
The USS class names to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveClasses<T>(T, List<string>?)
Removes a list of USS classes from the element.
public static T RemoveClasses<T>(this T element, List<string>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
The USS class names to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveClasses<T>(T, IEnumerable<string?>?)
Removes an enumerable of USS classes from the element.
public static T RemoveClasses<T>(this T element, IEnumerable<string?>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames IEnumerable<string?>?
The USS class names to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
classNames is copied before the first change, so it may read
GetClasses of this element, directly or through a LINQ query.
RemoveClasses<T>(T, ReadOnlySpan<string>)
Removes a read-only span of USS classes from the element.
public static T RemoveClasses<T>(this T element, ReadOnlySpan<string> classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames ReadOnlySpan<string>
The USS class names to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveClassesIf<T>(T, bool, params string?[]?)
Conditionally removes an array of USS classes from the element.
public static T RemoveClassesIf<T>(this T element, bool condition, params string?[]? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames string?[]?
The USS class names to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveClassesIf<T>(T, bool, List<string>?)
Conditionally removes a list of USS classes from the element.
public static T RemoveClassesIf<T>(this T element, bool condition, List<string>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
The USS class names to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveClassesIf<T>(T, bool, IEnumerable<string?>?)
Conditionally removes an enumerable of USS classes from the element.
public static T RemoveClassesIf<T>(this T element, bool condition, IEnumerable<string?>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames IEnumerable<string?>?
The USS class names to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
classNames is copied before the first change, so it may read
GetClasses of this element, directly or through a LINQ query.
RemoveClassesIf<T>(T, bool, ReadOnlySpan<string>)
Conditionally removes a read-only span of USS classes from the element.
public static T RemoveClassesIf<T>(this T element, bool condition, ReadOnlySpan<string> classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames ReadOnlySpan<string>
The USS class names to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveItalicUnityFontStyleAndWeight<T>(T)
Removes italic from unityFontStyleAndWeight, preserving any inline bold style.
public static T RemoveItalicUnityFontStyleAndWeight<T>(this T element) where T : VisualElement
Parameters
element T
The element to modify.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Transitions: Italic → Normal,
BoldAndItalic → Bold.
Other values are left unchanged.
Only the inline unityFontStyleAndWeight value is read; a bold or italic
style resolved from USS (with no inline value set) reports as Normal,
so nothing is written and the USS style stays, including the italic it was meant to remove.
RemoveStyleSheet<T>(T, StyleSheet?)
Removes a style sheet from styleSheets.
public static T RemoveStyleSheet<T>(this T element, StyleSheet? styleSheet) where T : VisualElement
Parameters
element T
The element to modify.
styleSheet StyleSheet?
The style sheet to remove; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheetFromResources<T>(T, string)
Loads a StyleSheet from Resources and removes it from styleSheets.
public static T RemoveStyleSheetFromResources<T>(this T element, string path) where T : VisualElement
Parameters
element T
The element to modify.
path string
The Resources-relative path to the style sheet asset.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
RemoveStyleSheetFromResourcesIf<T>(T, bool, string)
Conditionally loads a StyleSheet from Resources and removes it from styleSheets.
public static T RemoveStyleSheetFromResourcesIf<T>(this T element, bool condition, string path) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
path string
The Resources-relative path to the style sheet asset.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
RemoveStyleSheetIf<T>(T, bool, StyleSheet?)
Conditionally removes a style sheet from styleSheets.
public static T RemoveStyleSheetIf<T>(this T element, bool condition, StyleSheet? styleSheet) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheet StyleSheet?
The style sheet to remove; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheets<T>(T, params StyleSheet?[]?)
Removes an array of style sheets from styleSheets.
public static T RemoveStyleSheets<T>(this T element, params StyleSheet?[]? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
styleSheets StyleSheet?[]?
The style sheets to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheets<T>(T, List<StyleSheet>?)
Removes a list of style sheets from styleSheets.
public static T RemoveStyleSheets<T>(this T element, List<StyleSheet>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
styleSheets List<StyleSheet>?
The style sheets to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheets<T>(T, IEnumerable<StyleSheet?>?)
Removes an enumerable of style sheets from styleSheets.
public static T RemoveStyleSheets<T>(this T element, IEnumerable<StyleSheet?>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
styleSheets IEnumerable<StyleSheet?>?
The style sheets to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheets<T>(T, ReadOnlySpan<StyleSheet>)
Removes a read-only span of style sheets from styleSheets.
public static T RemoveStyleSheets<T>(this T element, ReadOnlySpan<StyleSheet> styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
styleSheets ReadOnlySpan<StyleSheet>
The style sheets to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheetsFromResources<T>(T, params string[]?)
Loads style sheets from an array of Resources paths and removes them from styleSheets.
public static T RemoveStyleSheetsFromResources<T>(this T element, params string[]? paths) where T : VisualElement
Parameters
element T
The element to modify.
paths string[]?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
RemoveStyleSheetsFromResources<T>(T, List<string>?)
Loads style sheets from a list of Resources paths and removes them from styleSheets.
public static T RemoveStyleSheetsFromResources<T>(this T element, List<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
RemoveStyleSheetsFromResources<T>(T, IEnumerable<string>?)
Loads style sheets from an enumerable of Resources paths and removes them from styleSheets.
public static T RemoveStyleSheetsFromResources<T>(this T element, IEnumerable<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
paths IEnumerable<string>?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
RemoveStyleSheetsFromResources<T>(T, ReadOnlySpan<string>)
Loads style sheets from a read-only span of Resources paths and removes them from styleSheets.
public static T RemoveStyleSheetsFromResources<T>(this T element, ReadOnlySpan<string> paths) where T : VisualElement
Parameters
element T
The element to modify.
paths ReadOnlySpan<string>
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
RemoveStyleSheetsFromResourcesIf<T>(T, bool, params string[]?)
Conditionally loads style sheets from an array of Resources paths and removes them from styleSheets.
public static T RemoveStyleSheetsFromResourcesIf<T>(this T element, bool condition, params string[]? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
paths string[]?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
RemoveStyleSheetsFromResourcesIf<T>(T, bool, List<string>?)
Conditionally loads style sheets from a list of Resources paths and removes them from styleSheets.
public static T RemoveStyleSheetsFromResourcesIf<T>(this T element, bool condition, List<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
RemoveStyleSheetsFromResourcesIf<T>(T, bool, IEnumerable<string>?)
Conditionally loads style sheets from an enumerable of Resources paths and removes them from styleSheets.
public static T RemoveStyleSheetsFromResourcesIf<T>(this T element, bool condition, IEnumerable<string>? paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
paths IEnumerable<string>?
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
RemoveStyleSheetsFromResourcesIf<T>(T, bool, ReadOnlySpan<string>)
Conditionally loads style sheets from a read-only span of Resources paths and removes them from styleSheets.
public static T RemoveStyleSheetsFromResourcesIf<T>(this T element, bool condition, ReadOnlySpan<string> paths) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
paths ReadOnlySpan<string>
The Resources-relative paths to the style sheet assets.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning for each path where no asset is found and skips that path.
RemoveStyleSheetsIf<T>(T, bool, params StyleSheet?[]?)
Conditionally removes an array of style sheets from styleSheets.
public static T RemoveStyleSheetsIf<T>(this T element, bool condition, params StyleSheet?[]? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheets StyleSheet?[]?
The style sheets to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheetsIf<T>(T, bool, List<StyleSheet>?)
Conditionally removes a list of style sheets from styleSheets.
public static T RemoveStyleSheetsIf<T>(this T element, bool condition, List<StyleSheet>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheets List<StyleSheet>?
The style sheets to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheetsIf<T>(T, bool, IEnumerable<StyleSheet?>?)
Conditionally removes an enumerable of style sheets from styleSheets.
public static T RemoveStyleSheetsIf<T>(this T element, bool condition, IEnumerable<StyleSheet?>? styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheets IEnumerable<StyleSheet?>?
The style sheets to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
RemoveStyleSheetsIf<T>(T, bool, ReadOnlySpan<StyleSheet>)
Conditionally removes a read-only span of style sheets from styleSheets.
public static T RemoveStyleSheetsIf<T>(this T element, bool condition, ReadOnlySpan<StyleSheet> styleSheets) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
styleSheets ReadOnlySpan<StyleSheet>
The style sheets to remove; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetAlignContent<T>(T, StyleEnum<Align>)
Sets alignContent.
public static T SetAlignContent<T>(this T element, StyleEnum<Align> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<Align>
The content alignment to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetAlignContent<T>(T, Align)
Sets alignContent.
public static T SetAlignContent<T>(this T element, Align value) where T : VisualElement
Parameters
element T
The element to modify.
value Align
The content alignment to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetAlignItems<T>(T, StyleEnum<Align>)
Sets alignItems.
public static T SetAlignItems<T>(this T element, StyleEnum<Align> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<Align>
The children alignment to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetAlignItems<T>(T, Align)
Sets alignItems.
public static T SetAlignItems<T>(this T element, Align value) where T : VisualElement
Parameters
element T
The element to modify.
value Align
The children alignment to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetAlignSelf<T>(T, StyleEnum<Align>)
Sets alignSelf.
public static T SetAlignSelf<T>(this T element, StyleEnum<Align> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<Align>
The alignment to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetAlignSelf<T>(T, Align)
Sets alignSelf.
public static T SetAlignSelf<T>(this T element, Align value) where T : VisualElement
Parameters
element T
The element to modify.
value Align
The alignment to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetAspectRatio<T>(T, StyleRatio)
Sets aspectRatio.
public static T SetAspectRatio<T>(this T element, StyleRatio value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleRatio
The aspect ratio to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Available in Unity 6000.3 and newer.
SetBackgroundColor<T>(T, StyleColor)
Sets backgroundColor.
public static T SetBackgroundColor<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The background color to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundColor<T>(T, string)
Sets backgroundColor from an HTML color string.
public static T SetBackgroundColor<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetBackgroundImage<T>(T, StyleBackground)
Sets backgroundImage.
public static T SetBackgroundImage<T>(this T element, StyleBackground value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleBackground
The background image to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundImage<T>(T, Sprite)
Sets backgroundImage to a Sprite.
public static T SetBackgroundImage<T>(this T element, Sprite value) where T : VisualElement
Parameters
element T
The element to modify.
value Sprite
The sprite to use as the background image.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundImage<T>(T, VectorImage)
Sets backgroundImage to a VectorImage.
public static T SetBackgroundImage<T>(this T element, VectorImage value) where T : VisualElement
Parameters
element T
The element to modify.
value VectorImage
The vector image to use as the background image.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundImageFromResources<T>(T, string)
Loads a Texture2D from Resources and sets the backgroundImage property.
public static T SetBackgroundImageFromResources<T>(this T element, string path) where T : VisualElement
Parameters
element T
The element to modify.
path string
The Resources path of the texture to load.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when no asset is found at path.
SetBackgroundPosition<T>(T, StyleBackgroundPosition)
Sets backgroundPositionX and backgroundPositionY.
public static T SetBackgroundPosition<T>(this T element, StyleBackgroundPosition value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleBackgroundPosition
The background position to apply to both axes.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundPosition<T>(T, StyleBackgroundPosition?, StyleBackgroundPosition?)
Sets backgroundPositionX and backgroundPositionY.
public static T SetBackgroundPosition<T>(this T element, StyleBackgroundPosition? x = null, StyleBackgroundPosition? y = null) where T : VisualElement
Parameters
element T
The element to modify.
x StyleBackgroundPosition?
The horizontal background position, or null to leave unchanged.
y StyleBackgroundPosition?
The vertical background position, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundPositionX<T>(T, StyleBackgroundPosition)
Sets backgroundPositionX.
public static T SetBackgroundPositionX<T>(this T element, StyleBackgroundPosition value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleBackgroundPosition
The horizontal background position to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundPositionY<T>(T, StyleBackgroundPosition)
Sets backgroundPositionY.
public static T SetBackgroundPositionY<T>(this T element, StyleBackgroundPosition value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleBackgroundPosition
The vertical background position to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundRepeat<T>(T, StyleBackgroundRepeat)
Sets backgroundRepeat.
public static T SetBackgroundRepeat<T>(this T element, StyleBackgroundRepeat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleBackgroundRepeat
The background repeat mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBackgroundSize<T>(T, StyleBackgroundSize)
Sets backgroundSize.
public static T SetBackgroundSize<T>(this T element, StyleBackgroundSize value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleBackgroundSize
The background size to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderColor<T>(T, StyleColor)
Sets borderTopColor, borderRightColor,
borderBottomColor and borderLeftColor.
public static T SetBorderColor<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The border color to apply to all sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderColor<T>(T, string)
Sets the border color on all sides from an HTML color string.
public static T SetBorderColor<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetBorderColor<T>(T, StyleColor?, StyleColor?, StyleColor?, StyleColor?)
Sets borderTopColor, borderRightColor,
borderBottomColor and borderLeftColor.
public static T SetBorderColor<T>(this T element, StyleColor? top = null, StyleColor? right = null, StyleColor? bottom = null, StyleColor? left = null) where T : VisualElement
Parameters
element T
The element to modify.
top StyleColor?
The top border color, or null to leave unchanged.
right StyleColor?
The right border color, or null to leave unchanged.
bottom StyleColor?
The bottom border color, or null to leave unchanged.
left StyleColor?
The left border color, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Positional arguments follow the order top, right, bottom, left, so
SetBorderColor(Color.red, Color.blue) sets the top and the right side, not the vertical and horizontal pairs.
Name the arguments, or use VisualElementExtensions.SetBorderColorY<T> and VisualElementExtensions.SetBorderColorX<T> for pairs.
SetBorderColorBottom<T>(T, StyleColor)
Sets borderBottomColor.
public static T SetBorderColorBottom<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The bottom border color to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderColorBottom<T>(T, string)
Sets the bottom border color from an HTML color string.
public static T SetBorderColorBottom<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetBorderColorLeft<T>(T, StyleColor)
Sets borderLeftColor.
public static T SetBorderColorLeft<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The left border color to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderColorLeft<T>(T, string)
Sets the left border color from an HTML color string.
public static T SetBorderColorLeft<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetBorderColorRight<T>(T, StyleColor)
Sets borderRightColor.
public static T SetBorderColorRight<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The right border color to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderColorRight<T>(T, string)
Sets the right border color from an HTML color string.
public static T SetBorderColorRight<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetBorderColorTop<T>(T, StyleColor)
Sets borderTopColor.
public static T SetBorderColorTop<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The top border color to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderColorTop<T>(T, string)
Sets the top border color from an HTML color string.
public static T SetBorderColorTop<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetBorderColorX<T>(T, StyleColor)
Sets borderRightColor and borderLeftColor.
public static T SetBorderColorX<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The border color to apply to the left and right sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderColorX<T>(T, string)
Sets the left and right border colors from an HTML color string.
public static T SetBorderColorX<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetBorderColorY<T>(T, StyleColor)
Sets borderTopColor and borderBottomColor.
public static T SetBorderColorY<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The border color to apply to the top and bottom sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderColorY<T>(T, string)
Sets the top and bottom border colors from an HTML color string.
public static T SetBorderColorY<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetBorderRadius<T>(T, StyleLength)
Sets borderTopLeftRadius, borderTopRightRadius,
borderBottomRightRadius and borderBottomLeftRadius.
public static T SetBorderRadius<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The border radius to apply to all corners.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderRadius<T>(T, StyleLength?, StyleLength?, StyleLength?, StyleLength?)
Sets borderTopLeftRadius, borderTopRightRadius,
borderBottomRightRadius and borderBottomLeftRadius.
public static T SetBorderRadius<T>(this T element, StyleLength? topLeft = null, StyleLength? topRight = null, StyleLength? bottomRight = null, StyleLength? bottomLeft = null) where T : VisualElement
Parameters
element T
The element to modify.
topLeft StyleLength?
The top-left radius, or null to leave unchanged.
topRight StyleLength?
The top-right radius, or null to leave unchanged.
bottomRight StyleLength?
The bottom-right radius, or null to leave unchanged.
bottomLeft StyleLength?
The bottom-left radius, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Positional arguments follow the order top-left, top-right, bottom-right, bottom-left, so
SetBorderRadius(8, 4) sets the top-left and the top-right corner, not the diagonal pairs.
SetBorderRadiusBottom<T>(T, StyleLength)
Sets borderBottomRightRadius and borderBottomLeftRadius.
public static T SetBorderRadiusBottom<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The radius to apply to both bottom corners.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderRadiusBottomLeft<T>(T, StyleLength)
Sets borderBottomLeftRadius.
public static T SetBorderRadiusBottomLeft<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The bottom-left corner radius to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderRadiusBottomRight<T>(T, StyleLength)
Sets borderBottomRightRadius.
public static T SetBorderRadiusBottomRight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The bottom-right corner radius to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderRadiusLeft<T>(T, StyleLength)
Sets borderTopLeftRadius and borderBottomLeftRadius.
public static T SetBorderRadiusLeft<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The radius to apply to both left corners.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderRadiusRight<T>(T, StyleLength)
Sets borderTopRightRadius and borderBottomRightRadius.
public static T SetBorderRadiusRight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The radius to apply to both right corners.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderRadiusTop<T>(T, StyleLength)
Sets borderTopLeftRadius and borderTopRightRadius.
public static T SetBorderRadiusTop<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The radius to apply to both top corners.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderRadiusTopLeft<T>(T, StyleLength)
Sets borderTopLeftRadius.
public static T SetBorderRadiusTopLeft<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The top-left corner radius to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderRadiusTopRight<T>(T, StyleLength)
Sets borderTopRightRadius.
public static T SetBorderRadiusTopRight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The top-right corner radius to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderWidth<T>(T, StyleFloat)
Sets borderTopWidth, borderRightWidth,
borderBottomWidth and borderLeftWidth.
public static T SetBorderWidth<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The border width to apply to all sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderWidth<T>(T, StyleFloat?, StyleFloat?, StyleFloat?, StyleFloat?)
Sets borderTopWidth, borderRightWidth,
borderBottomWidth and borderLeftWidth.
public static T SetBorderWidth<T>(this T element, StyleFloat? top = null, StyleFloat? right = null, StyleFloat? bottom = null, StyleFloat? left = null) where T : VisualElement
Parameters
element T
The element to modify.
top StyleFloat?
The top border width, or null to leave unchanged.
right StyleFloat?
The right border width, or null to leave unchanged.
bottom StyleFloat?
The bottom border width, or null to leave unchanged.
left StyleFloat?
The left border width, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Positional arguments follow the order top, right, bottom, left, so
SetBorderWidth(8, 4) sets the top and the right side, not the vertical and horizontal pairs.
Name the arguments, or use VisualElementExtensions.SetBorderWidthY<T> and VisualElementExtensions.SetBorderWidthX<T> for pairs.
SetBorderWidthBottom<T>(T, StyleFloat)
Sets borderBottomWidth.
public static T SetBorderWidthBottom<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The bottom border width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderWidthLeft<T>(T, StyleFloat)
Sets borderLeftWidth.
public static T SetBorderWidthLeft<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The left border width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderWidthRight<T>(T, StyleFloat)
Sets borderRightWidth.
public static T SetBorderWidthRight<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The right border width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderWidthTop<T>(T, StyleFloat)
Sets borderTopWidth.
public static T SetBorderWidthTop<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The top border width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderWidthX<T>(T, StyleFloat)
Sets borderLeftWidth and borderRightWidth.
public static T SetBorderWidthX<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The border width to apply to the left and right sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBorderWidthY<T>(T, StyleFloat)
Sets borderTopWidth and borderBottomWidth.
public static T SetBorderWidthY<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The border width to apply to the top and bottom sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetBottom<T>(T, StyleLength)
Sets bottom.
public static T SetBottom<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The bottom offset to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetColor<T>(T, StyleColor)
Sets color.
public static T SetColor<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The text color to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetColor<T>(T, string)
Sets color from an HTML color string.
public static T SetColor<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetCursor<T>(T, StyleCursor)
Sets cursor.
public static T SetCursor<T>(this T element, StyleCursor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleCursor
The cursor style to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetDataSource<T>(T, object)
Sets dataSource.
public static T SetDataSource<T>(this T element, object value) where T : VisualElement
Parameters
element T
The element to modify.
value object
The data source to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetDataSourcePath<T>(T, PropertyPath)
Sets dataSourcePath.
public static T SetDataSourcePath<T>(this T element, PropertyPath value) where T : VisualElement
Parameters
element T
The element to modify.
value PropertyPath
The data source path to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetDataSourceType<T>(T, Type)
Sets dataSourceType.
public static T SetDataSourceType<T>(this T element, Type value) where T : VisualElement
Parameters
element T
The element to modify.
value Type
The data source type to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
The type is only a design-time hint for the UI Builder; it does not affect runtime binding.
SetDisablePlayModeTint<T>(T, bool)
Sets disablePlayModeTint.
public static T SetDisablePlayModeTint<T>(this T element, bool value) where T : VisualElement
Parameters
element T
The element to modify.
value bool
When true, the play-mode tint is not applied to the element and its children.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetDisplay<T>(T, StyleEnum<DisplayStyle>)
Sets display.
public static T SetDisplay<T>(this T element, StyleEnum<DisplayStyle> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<DisplayStyle>
The display mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetDisplay<T>(T, DisplayStyle)
Sets display.
public static T SetDisplay<T>(this T element, DisplayStyle value) where T : VisualElement
Parameters
element T
The element to modify.
value DisplayStyle
The display mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetDistance<T>(T, StyleLength)
Sets top, right,
bottom and left.
public static T SetDistance<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The distance to apply to all sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetDistance<T>(T, StyleLength?, StyleLength?, StyleLength?, StyleLength?)
Sets top, right,
bottom and left.
public static T SetDistance<T>(this T element, StyleLength? top = null, StyleLength? right = null, StyleLength? bottom = null, StyleLength? left = null) where T : VisualElement
Parameters
element T
The element to modify.
top StyleLength?
The top offset, or null to leave unchanged.
right StyleLength?
The right offset, or null to leave unchanged.
bottom StyleLength?
The bottom offset, or null to leave unchanged.
left StyleLength?
The left offset, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Positional arguments follow the order top, right, bottom, left, so
SetDistance(8, 4) sets the top and the right offset, not the vertical and horizontal pairs.
Name the arguments, or use VisualElementExtensions.SetDistanceY<T> and VisualElementExtensions.SetDistanceX<T> for pairs.
SetDistanceX<T>(T, StyleLength)
public static T SetDistanceX<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The horizontal offset to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetDistanceY<T>(T, StyleLength)
public static T SetDistanceY<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The vertical offset to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetEnabledSelf<T>(T, bool)
Enables or disables the element via SetEnabled.
public static T SetEnabledSelf<T>(this T element, bool value) where T : VisualElement
Parameters
element T
The element to modify.
value bool
When true, the element is enabled; a disabled element receives most events no longer.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetFilter<T>(T, StyleList<FilterFunction>)
Sets filter.
public static T SetFilter<T>(this T element, StyleList<FilterFunction> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleList<FilterFunction>
The filter effects to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Available in Unity 6000.3 and newer.
SetFlexBasis<T>(T, StyleLength)
Sets flexBasis.
public static T SetFlexBasis<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The flex basis to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetFlexDirection<T>(T, StyleEnum<FlexDirection>)
Sets flexDirection.
public static T SetFlexDirection<T>(this T element, StyleEnum<FlexDirection> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<FlexDirection>
The flex direction to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetFlexDirection<T>(T, FlexDirection)
Sets flexDirection.
public static T SetFlexDirection<T>(this T element, FlexDirection value) where T : VisualElement
Parameters
element T
The element to modify.
value FlexDirection
The flex direction to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetFlexGrow<T>(T, StyleFloat)
Sets flexGrow.
public static T SetFlexGrow<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The flex grow factor to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetFlexShrink<T>(T, StyleFloat)
Sets flexShrink.
public static T SetFlexShrink<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The flex shrink factor to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetFlexWrap<T>(T, StyleEnum<Wrap>)
Sets flexWrap.
public static T SetFlexWrap<T>(this T element, StyleEnum<Wrap> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<Wrap>
The flex wrap mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetFlexWrap<T>(T, Wrap)
Sets flexWrap.
public static T SetFlexWrap<T>(this T element, Wrap value) where T : VisualElement
Parameters
element T
The element to modify.
value Wrap
The flex wrap mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetFontSize<T>(T, StyleLength)
Sets fontSize.
public static T SetFontSize<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The font size to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetHeight<T>(T, StyleLength)
Sets height.
public static T SetHeight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The height to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetJustifyContent<T>(T, StyleEnum<Justify>)
Sets justifyContent.
public static T SetJustifyContent<T>(this T element, StyleEnum<Justify> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<Justify>
The justify content mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetJustifyContent<T>(T, Justify)
Sets justifyContent.
public static T SetJustifyContent<T>(this T element, Justify value) where T : VisualElement
Parameters
element T
The element to modify.
value Justify
The justify content mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetLanguageDirection<T>(T, LanguageDirection)
Sets languageDirection.
public static T SetLanguageDirection<T>(this T element, LanguageDirection value) where T : VisualElement
Parameters
element T
The element to modify.
value LanguageDirection
The language direction to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetLeft<T>(T, StyleLength)
Sets left.
public static T SetLeft<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The left offset to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetLetterSpacing<T>(T, StyleLength)
Sets letterSpacing.
public static T SetLetterSpacing<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The letter spacing to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMargin<T>(T, StyleLength)
Sets marginTop, marginRight,
marginBottom and marginLeft.
public static T SetMargin<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The margin to apply to all sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMargin<T>(T, StyleLength?, StyleLength?, StyleLength?, StyleLength?)
Sets marginTop, marginRight,
marginBottom and marginLeft.
public static T SetMargin<T>(this T element, StyleLength? top = null, StyleLength? right = null, StyleLength? bottom = null, StyleLength? left = null) where T : VisualElement
Parameters
element T
The element to modify.
top StyleLength?
The top margin, or null to leave unchanged.
right StyleLength?
The right margin, or null to leave unchanged.
bottom StyleLength?
The bottom margin, or null to leave unchanged.
left StyleLength?
The left margin, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Positional arguments follow the order top, right, bottom, left, so
SetMargin(8, 4) sets the top and the right side, not the vertical and horizontal pairs.
Name the arguments, or use VisualElementExtensions.SetMarginY<T> and VisualElementExtensions.SetMarginX<T> for pairs.
SetMarginBottom<T>(T, StyleLength)
Sets marginBottom.
public static T SetMarginBottom<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The bottom margin to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMarginLeft<T>(T, StyleLength)
Sets marginLeft.
public static T SetMarginLeft<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The left margin to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMarginRight<T>(T, StyleLength)
Sets marginRight.
public static T SetMarginRight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The right margin to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMarginTop<T>(T, StyleLength)
Sets marginTop.
public static T SetMarginTop<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The top margin to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMarginX<T>(T, StyleLength)
Sets marginRight and marginLeft.
public static T SetMarginX<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The horizontal margin to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMarginY<T>(T, StyleLength)
Sets marginTop and marginBottom.
public static T SetMarginY<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The vertical margin to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMaxHeight<T>(T, StyleLength)
Sets maxHeight.
public static T SetMaxHeight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The maximum height to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMaxSize<T>(T, StyleLength)
public static T SetMaxSize<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The maximum size to apply to both width and height.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMaxSize<T>(T, StyleLength?, StyleLength?)
public static T SetMaxSize<T>(this T element, StyleLength? maxWidth = null, StyleLength? maxHeight = null) where T : VisualElement
Parameters
element T
The element to modify.
maxWidth StyleLength?
The maximum width to set, or null to leave unchanged.
maxHeight StyleLength?
The maximum height to set, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMaxWidth<T>(T, StyleLength)
Sets maxWidth.
public static T SetMaxWidth<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The maximum width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMinHeight<T>(T, StyleLength)
Sets minHeight.
public static T SetMinHeight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The minimum height to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMinSize<T>(T, StyleLength)
public static T SetMinSize<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The minimum size to apply to both width and height.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMinSize<T>(T, StyleLength?, StyleLength?)
public static T SetMinSize<T>(this T element, StyleLength? minWidth = null, StyleLength? minHeight = null) where T : VisualElement
Parameters
element T
The element to modify.
minWidth StyleLength?
The minimum width to set, or null to leave unchanged.
minHeight StyleLength?
The minimum height to set, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetMinWidth<T>(T, StyleLength)
Sets minWidth.
public static T SetMinWidth<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The minimum width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetName<T>(T, string)
Sets name.
public static T SetName<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The name to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetNormalUnityFontStyleAndWeight<T>(T)
Sets unityFontStyleAndWeight to Normal, removing bold and italic.
public static T SetNormalUnityFontStyleAndWeight<T>(this T element) where T : VisualElement
Parameters
element T
The element to modify.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Sets the value unconditionally, regardless of any current bold or italic style.
SetOpacity<T>(T, StyleFloat)
Sets opacity.
public static T SetOpacity<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The opacity to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetOverflow<T>(T, StyleEnum<Overflow>)
Sets overflow.
public static T SetOverflow<T>(this T element, StyleEnum<Overflow> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<Overflow>
The overflow behavior to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetOverflow<T>(T, Overflow)
Sets overflow.
public static T SetOverflow<T>(this T element, Overflow value) where T : VisualElement
Parameters
element T
The element to modify.
value Overflow
The overflow behavior to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPadding<T>(T, StyleLength)
Sets paddingTop, paddingRight,
paddingBottom and paddingLeft.
public static T SetPadding<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The padding to apply to all sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPadding<T>(T, StyleLength?, StyleLength?, StyleLength?, StyleLength?)
Sets paddingTop, paddingRight,
paddingBottom and paddingLeft.
public static T SetPadding<T>(this T element, StyleLength? top = null, StyleLength? right = null, StyleLength? bottom = null, StyleLength? left = null) where T : VisualElement
Parameters
element T
The element to modify.
top StyleLength?
The top padding, or null to leave unchanged.
right StyleLength?
The right padding, or null to leave unchanged.
bottom StyleLength?
The bottom padding, or null to leave unchanged.
left StyleLength?
The left padding, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Positional arguments follow the order top, right, bottom, left, so
SetPadding(8, 4) sets the top and the right side, not the vertical and horizontal pairs.
Name the arguments, or use VisualElementExtensions.SetPaddingY<T> and VisualElementExtensions.SetPaddingX<T> for pairs.
SetPaddingBottom<T>(T, StyleLength)
Sets paddingBottom.
public static T SetPaddingBottom<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The bottom padding to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPaddingLeft<T>(T, StyleLength)
Sets paddingLeft.
public static T SetPaddingLeft<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The left padding to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPaddingRight<T>(T, StyleLength)
Sets paddingRight.
public static T SetPaddingRight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The right padding to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPaddingTop<T>(T, StyleLength)
Sets paddingTop.
public static T SetPaddingTop<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The top padding to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPaddingX<T>(T, StyleLength)
Sets paddingRight and paddingLeft.
public static T SetPaddingX<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The horizontal padding to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPaddingY<T>(T, StyleLength)
Sets paddingTop and paddingBottom.
public static T SetPaddingY<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The vertical padding to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPickingMode<T>(T, PickingMode)
Sets pickingMode.
public static T SetPickingMode<T>(this T element, PickingMode value) where T : VisualElement
Parameters
element T
The element to modify.
value PickingMode
The picking mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPosition<T>(T, StyleEnum<Position>)
Sets position.
public static T SetPosition<T>(this T element, StyleEnum<Position> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<Position>
The position type to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetPosition<T>(T, Position)
Sets position.
public static T SetPosition<T>(this T element, Position value) where T : VisualElement
Parameters
element T
The element to modify.
value Position
The position type to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetRight<T>(T, StyleLength)
Sets right.
public static T SetRight<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The right offset to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetRotate<T>(T, StyleRotate)
Sets rotate.
public static T SetRotate<T>(this T element, StyleRotate value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleRotate
The rotation to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetScale<T>(T, StyleScale)
Sets scale.
public static T SetScale<T>(this T element, StyleScale value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleScale
The scale transformation to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetSize<T>(T, StyleLength)
public static T SetSize<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The size to apply to both width and height.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetSize<T>(T, StyleLength?, StyleLength?)
public static T SetSize<T>(this T element, StyleLength? width = null, StyleLength? height = null) where T : VisualElement
Parameters
element T
The element to modify.
width StyleLength?
The width to set, or null to leave unchanged.
height StyleLength?
The height to set, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTextOverflow<T>(T, StyleEnum<TextOverflow>)
Sets textOverflow.
public static T SetTextOverflow<T>(this T element, StyleEnum<TextOverflow> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<TextOverflow>
The text overflow mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTextOverflow<T>(T, TextOverflow)
Sets textOverflow.
public static T SetTextOverflow<T>(this T element, TextOverflow value) where T : VisualElement
Parameters
element T
The element to modify.
value TextOverflow
The text overflow mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTextShadow<T>(T, StyleTextShadow)
Sets textShadow.
public static T SetTextShadow<T>(this T element, StyleTextShadow value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleTextShadow
The text shadow to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTooltip<T>(T, string)
Sets tooltip.
public static T SetTooltip<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The tooltip text to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTop<T>(T, StyleLength)
Sets top.
public static T SetTop<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The top offset to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTransformOrigin<T>(T, StyleTransformOrigin)
Sets transformOrigin.
public static T SetTransformOrigin<T>(this T element, StyleTransformOrigin value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleTransformOrigin
The transform origin to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTransitionDelay<T>(T, StyleList<TimeValue>)
Sets transitionDelay.
public static T SetTransitionDelay<T>(this T element, StyleList<TimeValue> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleList<TimeValue>
The transition delays to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTransitionDuration<T>(T, StyleList<TimeValue>)
Sets transitionDuration.
public static T SetTransitionDuration<T>(this T element, StyleList<TimeValue> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleList<TimeValue>
The transition durations to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTransitionProperty<T>(T, StyleList<StylePropertyName>)
Sets transitionProperty.
public static T SetTransitionProperty<T>(this T element, StyleList<StylePropertyName> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleList<StylePropertyName>
The transition properties to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTransitionTimingFunction<T>(T, StyleList<EasingFunction>)
Sets transitionTimingFunction.
public static T SetTransitionTimingFunction<T>(this T element, StyleList<EasingFunction> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleList<EasingFunction>
The transition timing functions to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetTranslate<T>(T, StyleTranslate)
Sets translate.
public static T SetTranslate<T>(this T element, StyleTranslate value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleTranslate
The translation to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityBackgroundImageTintColor<T>(T, StyleColor)
Sets unityBackgroundImageTintColor.
public static T SetUnityBackgroundImageTintColor<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The background image tint color to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityBackgroundImageTintColor<T>(T, string)
Sets the background image tint color from an HTML color string.
public static T SetUnityBackgroundImageTintColor<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetUnityEditorTextRenderingMode<T>(T, StyleEnum<EditorTextRenderingMode>)
Sets unityEditorTextRenderingMode.
public static T SetUnityEditorTextRenderingMode<T>(this T element, StyleEnum<EditorTextRenderingMode> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<EditorTextRenderingMode>
The editor text rendering mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityEditorTextRenderingMode<T>(T, EditorTextRenderingMode)
Sets unityEditorTextRenderingMode.
public static T SetUnityEditorTextRenderingMode<T>(this T element, EditorTextRenderingMode value) where T : VisualElement
Parameters
element T
The element to modify.
value EditorTextRenderingMode
The editor text rendering mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityFont<T>(T, StyleFont)
Sets unityFont.
public static T SetUnityFont<T>(this T element, StyleFont value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFont
The font to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityFontDefinition<T>(T, StyleFontDefinition)
Sets unityFontDefinition.
public static T SetUnityFontDefinition<T>(this T element, StyleFontDefinition value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFontDefinition
The font definition to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityFontStyleAndWeight<T>(T, StyleEnum<FontStyle>)
Sets unityFontStyleAndWeight.
public static T SetUnityFontStyleAndWeight<T>(this T element, StyleEnum<FontStyle> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<FontStyle>
The font style and weight to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityFontStyleAndWeight<T>(T, FontStyle)
Sets unityFontStyleAndWeight.
public static T SetUnityFontStyleAndWeight<T>(this T element, FontStyle value) where T : VisualElement
Parameters
element T
The element to modify.
value FontStyle
The font style and weight to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityMaterial<T>(T, StyleMaterialDefinition)
Sets unityMaterial.
public static T SetUnityMaterial<T>(this T element, StyleMaterialDefinition value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleMaterialDefinition
The material to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Available in Unity 6000.3 and newer.
SetUnityOverflowClipBox<T>(T, StyleEnum<OverflowClipBox>)
Sets unityOverflowClipBox.
public static T SetUnityOverflowClipBox<T>(this T element, StyleEnum<OverflowClipBox> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<OverflowClipBox>
The overflow clip box to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityOverflowClipBox<T>(T, OverflowClipBox)
Sets unityOverflowClipBox.
public static T SetUnityOverflowClipBox<T>(this T element, OverflowClipBox value) where T : VisualElement
Parameters
element T
The element to modify.
value OverflowClipBox
The overflow clip box to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityParagraphSpacing<T>(T, StyleLength)
Sets unityParagraphSpacing.
public static T SetUnityParagraphSpacing<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The paragraph spacing to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySlice<T>(T, StyleInt)
Sets unitySliceTop, unitySliceRight,
unitySliceBottom and unitySliceLeft.
public static T SetUnitySlice<T>(this T element, StyleInt value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleInt
The slice width to apply to all sides.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySlice<T>(T, StyleInt?, StyleInt?, StyleInt?, StyleInt?)
Sets unitySliceTop, unitySliceRight,
unitySliceBottom and unitySliceLeft.
public static T SetUnitySlice<T>(this T element, StyleInt? top = null, StyleInt? right = null, StyleInt? bottom = null, StyleInt? left = null) where T : VisualElement
Parameters
element T
The element to modify.
top StyleInt?
The top slice width, or null to leave unchanged.
right StyleInt?
The right slice width, or null to leave unchanged.
bottom StyleInt?
The bottom slice width, or null to leave unchanged.
left StyleInt?
The left slice width, or null to leave unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceBottom<T>(T, StyleInt)
Sets unitySliceBottom.
public static T SetUnitySliceBottom<T>(this T element, StyleInt value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleInt
The bottom slice width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceLeft<T>(T, StyleInt)
Sets unitySliceLeft.
public static T SetUnitySliceLeft<T>(this T element, StyleInt value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleInt
The left slice width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceRight<T>(T, StyleInt)
Sets unitySliceRight.
public static T SetUnitySliceRight<T>(this T element, StyleInt value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleInt
The right slice width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceScale<T>(T, StyleFloat)
Sets unitySliceScale.
public static T SetUnitySliceScale<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The slice scale to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceTop<T>(T, StyleInt)
Sets unitySliceTop.
public static T SetUnitySliceTop<T>(this T element, StyleInt value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleInt
The top slice width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceType<T>(T, StyleEnum<SliceType>)
Sets unitySliceType.
public static T SetUnitySliceType<T>(this T element, StyleEnum<SliceType> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<SliceType>
The slice type to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceType<T>(T, SliceType)
Sets unitySliceType.
public static T SetUnitySliceType<T>(this T element, SliceType value) where T : VisualElement
Parameters
element T
The element to modify.
value SliceType
The slice type to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceX<T>(T, StyleInt)
Sets unitySliceRight and unitySliceLeft.
public static T SetUnitySliceX<T>(this T element, StyleInt value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleInt
The horizontal slice width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnitySliceY<T>(T, StyleInt)
Sets unitySliceTop and unitySliceBottom.
public static T SetUnitySliceY<T>(this T element, StyleInt value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleInt
The vertical slice width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityTextAlign<T>(T, StyleEnum<TextAnchor>)
Sets unityTextAlign.
public static T SetUnityTextAlign<T>(this T element, StyleEnum<TextAnchor> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<TextAnchor>
The text alignment to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityTextAlign<T>(T, TextAnchor)
Sets unityTextAlign.
public static T SetUnityTextAlign<T>(this T element, TextAnchor value) where T : VisualElement
Parameters
element T
The element to modify.
value TextAnchor
The text alignment to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityTextAutoSize<T>(T, StyleTextAutoSize)
Sets unityTextAutoSize.
public static T SetUnityTextAutoSize<T>(this T element, StyleTextAutoSize value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleTextAutoSize
The text auto size settings to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Available in Unity 6000.2 and newer.
SetUnityTextGenerator<T>(T, StyleEnum<TextGeneratorType>)
Sets unityTextGenerator.
public static T SetUnityTextGenerator<T>(this T element, StyleEnum<TextGeneratorType> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<TextGeneratorType>
The text generator type to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityTextGenerator<T>(T, TextGeneratorType)
Sets unityTextGenerator.
public static T SetUnityTextGenerator<T>(this T element, TextGeneratorType value) where T : VisualElement
Parameters
element T
The element to modify.
value TextGeneratorType
The text generator type to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityTextOutlineColor<T>(T, StyleColor)
Sets unityTextOutlineColor.
public static T SetUnityTextOutlineColor<T>(this T element, StyleColor value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleColor
The text outline color to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityTextOutlineColor<T>(T, string)
Sets the text outline color from an HTML color string.
public static T SetUnityTextOutlineColor<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The HTML color string, such as #FF0000 or red.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Logs a warning and leaves the element unchanged when value cannot be parsed.
SetUnityTextOutlineWidth<T>(T, StyleFloat)
Sets unityTextOutlineWidth.
public static T SetUnityTextOutlineWidth<T>(this T element, StyleFloat value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleFloat
The text outline width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityTextOverflowPosition<T>(T, StyleEnum<TextOverflowPosition>)
Sets unityTextOverflowPosition.
public static T SetUnityTextOverflowPosition<T>(this T element, StyleEnum<TextOverflowPosition> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<TextOverflowPosition>
The text overflow position to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUnityTextOverflowPosition<T>(T, TextOverflowPosition)
Sets unityTextOverflowPosition.
public static T SetUnityTextOverflowPosition<T>(this T element, TextOverflowPosition value) where T : VisualElement
Parameters
element T
The element to modify.
value TextOverflowPosition
The text overflow position to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetUsageHints<T>(T, UsageHints)
Sets usageHints.
public static T SetUsageHints<T>(this T element, UsageHints value) where T : VisualElement
Parameters
element T
The element to modify.
value UsageHints
The usage hints to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
Unity recommends setting the hints before the element is added to a panel. Changing them afterward does not throw, but triggers a render-hints update.
SetUserData<T>(T, object)
Sets userData.
public static T SetUserData<T>(this T element, object value) where T : VisualElement
Parameters
element T
The element to modify.
value object
The user data to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetViewDataKey<T>(T, string)
Sets viewDataKey.
public static T SetViewDataKey<T>(this T element, string value) where T : VisualElement
Parameters
element T
The element to modify.
value string
The view data key to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetVisibility<T>(T, StyleEnum<Visibility>)
Sets visibility.
public static T SetVisibility<T>(this T element, StyleEnum<Visibility> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<Visibility>
The visibility to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetVisibility<T>(T, Visibility)
Sets visibility.
public static T SetVisibility<T>(this T element, Visibility value) where T : VisualElement
Parameters
element T
The element to modify.
value Visibility
The visibility to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetVisible<T>(T, bool)
Sets visible.
public static T SetVisible<T>(this T element, bool value) where T : VisualElement
Parameters
element T
The element to modify.
value bool
When true, the element is rendered.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetWhiteSpace<T>(T, StyleEnum<WhiteSpace>)
Sets whiteSpace.
public static T SetWhiteSpace<T>(this T element, StyleEnum<WhiteSpace> value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleEnum<WhiteSpace>
The white-space mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetWhiteSpace<T>(T, WhiteSpace)
Sets whiteSpace.
public static T SetWhiteSpace<T>(this T element, WhiteSpace value) where T : VisualElement
Parameters
element T
The element to modify.
value WhiteSpace
The white-space mode to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetWidth<T>(T, StyleLength)
Sets width.
public static T SetWidth<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The width to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
SetWordSpacing<T>(T, StyleLength)
Sets wordSpacing.
public static T SetWordSpacing<T>(this T element, StyleLength value) where T : VisualElement
Parameters
element T
The element to modify.
value StyleLength
The word spacing to set.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ToggleClass<T>(T, string?)
Adds the USS class when it is absent and removes it when it is present.
public static T ToggleClass<T>(this T element, string? className) where T : VisualElement
Parameters
element T
The element to modify.
className string?
The USS class name to toggle; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ToggleClassIf<T>(T, bool, string?)
Conditionally adds the USS class when it is absent and removes it when it is present.
public static T ToggleClassIf<T>(this T element, bool condition, string? className) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
className string?
The USS class name to toggle; null leaves the element unchanged.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ToggleClasses<T>(T, params string?[]?)
Adds each USS class of an array when it is absent and removes it when it is present.
public static T ToggleClasses<T>(this T element, params string?[]? classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames string?[]?
The USS class names to toggle; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ToggleClasses<T>(T, List<string>?)
Adds each USS class of a list when it is absent and removes it when it is present.
public static T ToggleClasses<T>(this T element, List<string>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
The USS class names to toggle; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ToggleClasses<T>(T, IEnumerable<string?>?)
Adds each USS class of an enumerable when it is absent and removes it when it is present.
public static T ToggleClasses<T>(this T element, IEnumerable<string?>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames IEnumerable<string?>?
The USS class names to toggle; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
classNames is copied before the first change, so it may read
GetClasses of this element, directly or through a LINQ query.
ToggleClasses<T>(T, ReadOnlySpan<string>)
Adds each USS class of a read-only span when it is absent and removes it when it is present.
public static T ToggleClasses<T>(this T element, ReadOnlySpan<string> classNames) where T : VisualElement
Parameters
element T
The element to modify.
classNames ReadOnlySpan<string>
The USS class names to toggle; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ToggleClassesIf<T>(T, bool, params string?[]?)
Conditionally adds each USS class of an array when it is absent and removes it when it is present.
public static T ToggleClassesIf<T>(this T element, bool condition, params string?[]? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames string?[]?
The USS class names to toggle; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ToggleClassesIf<T>(T, bool, List<string>?)
Conditionally adds each USS class of a list when it is absent and removes it when it is present.
public static T ToggleClassesIf<T>(this T element, bool condition, List<string>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
The USS class names to toggle; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
ToggleClassesIf<T>(T, bool, IEnumerable<string?>?)
Conditionally adds each USS class of an enumerable when it is absent and removes it when it is present.
public static T ToggleClassesIf<T>(this T element, bool condition, IEnumerable<string?>? classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames IEnumerable<string?>?
The USS class names to toggle; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.
Remarks
classNames is copied before the first change, so it may read
GetClasses of this element, directly or through a LINQ query.
ToggleClassesIf<T>(T, bool, ReadOnlySpan<string>)
Conditionally adds each USS class of a read-only span when it is absent and removes it when it is present.
public static T ToggleClassesIf<T>(this T element, bool condition, ReadOnlySpan<string> classNames) where T : VisualElement
Parameters
element T
The element to modify.
condition bool
When true, the operation is performed; otherwise, the element is returned unchanged.
classNames ReadOnlySpan<string>
The USS class names to toggle; null entries are skipped.
Returns
T
The element, for chaining.
Type Parameters
T
The element type.