Struct UQueryBuilder<T>
Utility Object that contructs a set of selection rules to be ran on a root visual element.
Syntax
public struct UQueryBuilder<T> : IEquatable<UQueryBuilder<T>> where T : VisualElement
Type Parameters
Constructors
UQueryBuilder(VisualElement)
Initializes a QueryBuilder.
Declaration
public UQueryBuilder(VisualElement visualElement)
Parameters
Type |
Name |
Description |
VisualElement |
visualElement |
The root element on which to condfuct the search query.
|
Methods
Active()
Selects all elements that are active.
Declaration
public UQueryBuilder<T> Active()
Returns
Type |
Description |
UQueryBuilder<T> |
A QueryBuilder with the selection rules.
|
AtIndex(Int32)
Convenience overload, shorthand for Build().AtIndex().
Declaration
public T AtIndex(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
See Also
Build()
Compiles the selection rules into a QueryState object.
Declaration
public UQueryState<T> Build()
Returns
Checked()
Selects all elements that are checked.
Declaration
public UQueryBuilder<T> Checked()
Returns
Children<T2>(String, String)
Selects all direct child elements of elements matching the previous rules.
Declaration
public UQueryBuilder<T2> Children<T2>(string name = null, string className = null)
where T2 : VisualElement
Parameters
Returns
Type Parameters
Children<T2>(String, String[])
Selects all direct child elements of elements matching the previous rules.
Declaration
public UQueryBuilder<T2> Children<T2>(string name = null, params string[] classes)
where T2 : VisualElement
Parameters
Returns
Type Parameters
Class(String)
Selects all elements with the specified class in the class list, as specified with the class
attribute in a UXML file or added with AddToClassList(String) method.
Declaration
public UQueryBuilder<T> Class(string classname)
Parameters
Type |
Name |
Description |
String |
classname |
The class to use in the query.
|
Returns
Descendents<T2>(String, String)
Selects all elements that are descendants of currently matching ancestors.
Declaration
public UQueryBuilder<T2> Descendents<T2>(string name = null, string classname = null)
where T2 : VisualElement
Parameters
Returns
Type Parameters
Descendents<T2>(String, String[])
Selects all elements that are descendants of currently matching ancestors.
Declaration
public UQueryBuilder<T2> Descendents<T2>(string name = null, params string[] classNames)
where T2 : VisualElement
Parameters
Returns
Type Parameters
Enabled()
Selects all elements that are enabled.
Declaration
public UQueryBuilder<T> Enabled()
Returns
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
Object |
obj |
|
Returns
Equals(UQueryBuilder<T>)
Declaration
public bool Equals(UQueryBuilder<T> other)
Parameters
Returns
First()
Convenience overload, shorthand for Build().First().
Declaration
Returns
Type |
Description |
T |
The first element matching all the criteria, or null if none was found.
|
See Also
Focused()
Selects all elements that are enabled.
Declaration
public UQueryBuilder<T> Focused()
Returns
ForEach(Action<T>)
Convenience overload, shorthand for Build().ForEach().
Declaration
public void ForEach(Action<T> funcCall)
Parameters
Type |
Name |
Description |
Action<T> |
funcCall |
The function to be invoked with each matching element.
|
ForEach<T2>(Func<T, T2>)
Convenience overload, shorthand for Build().ForEach().
Declaration
public List<T2> ForEach<T2>(Func<T, T2> funcCall)
Parameters
Type |
Name |
Description |
Func<T, T2> |
funcCall |
The function to be invoked with each matching element.
|
Returns
Type |
Description |
List<T2> |
|
Type Parameters
ForEach<T2>(List<T2>, Func<T, T2>)
Convenience overload, shorthand for Build().ForEach().
Declaration
public void ForEach<T2>(List<T2> result, Func<T, T2> funcCall)
Parameters
Type |
Name |
Description |
List<T2> |
result |
Each return value will be added to this list.
|
Func<T, T2> |
funcCall |
The function to be invoked with each matching element.
|
Type Parameters
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Hovered()
Selects all elements that are hovered.
Declaration
public UQueryBuilder<T> Hovered()
Returns
Last()
Convenience overload, shorthand for Build().Last().
Declaration
Returns
Type |
Description |
T |
The last element matching all the criteria, or null if none was found.
|
Name(String)
Selects element with this name.
Declaration
public UQueryBuilder<T> Name(string id)
Parameters
Type |
Name |
Description |
String |
id |
|
Returns
NotActive()
Selects all elements that are not active.
Declaration
public UQueryBuilder<T> NotActive()
Returns
NotChecked()
Selects all elements that npot checked.
Declaration
public UQueryBuilder<T> NotChecked()
Returns
NotEnabled()
Selects all elements that are not enabled.
Declaration
public UQueryBuilder<T> NotEnabled()
Returns
NotFocused()
Selects all elements that don't currently own the focus.
Declaration
public UQueryBuilder<T> NotFocused()
Returns
NotHovered()
Selects all elements that are not hovered.
Declaration
public UQueryBuilder<T> NotHovered()
Returns
NotSelected()
Selects all elements that are not selected.
Declaration
public UQueryBuilder<T> NotSelected()
Returns
NotVisible()
Selects all elements that are not visible.
Declaration
public UQueryBuilder<T> NotVisible()
Returns
OfType<T2>(String, String)
Selects all elements of the specified Type (eg: Label, Button, ScrollView, etc).
Declaration
public UQueryBuilder<T2> OfType<T2>(string name = null, string className = null)
where T2 : VisualElement
Parameters
Type |
Name |
Description |
String |
name |
If specified, will select elements with this name.
|
String |
className |
If specified, will select elements with the given class (not to be confused with Type).
|
Returns
Type |
Description |
UQueryBuilder<T2> |
QueryBuilder configured with the associated selection rules.
|
Type Parameters
OfType<T2>(String, String[])
Selects all elements of the specified Type (eg: Label, Button, ScrollView, etc).
Declaration
public UQueryBuilder<T2> OfType<T2>(string name = null, params string[] classes)
where T2 : VisualElement
Parameters
Type |
Name |
Description |
String |
name |
If specified, will select elements with this name.
|
String[] |
classes |
If specified, will select elements with the given class (not to be confused with Type).
|
Returns
Type |
Description |
UQueryBuilder<T2> |
QueryBuilder configured with the associated selection rules.
|
Type Parameters
Selected()
Selects all elements that are not selected.
Declaration
public UQueryBuilder<T> Selected()
Returns
ToList()
Convenience method. shorthand for Build().ToList.
Declaration
Returns
Type |
Description |
List<T> |
A list containing elements satisfying selection rules.
|
ToList(List<T>)
Convenience method. Shorthand gor Build().ToList().
Declaration
public void ToList(List<T> results)
Parameters
Type |
Name |
Description |
List<T> |
results |
Adds all elements satisfying selection rules to the list.
|
Visible()
Selects all elements that are not visible.
Declaration
public UQueryBuilder<T> Visible()
Returns
Where(Func<T, Boolean>)
Selects all elements satifying the predicate.
Declaration
public UQueryBuilder<T> Where(Func<T, bool> selectorPredicate)
Parameters
Type |
Name |
Description |
Func<T, Boolean> |
selectorPredicate |
Predicate that must return true for selected elements.
|
Returns
Type |
Description |
UQueryBuilder<T> |
QueryBuilder configured with the associated selection rules.
|
Operators
Equality(UQueryBuilder<T>, UQueryBuilder<T>)
Declaration
public static bool operator ==(UQueryBuilder<T> builder1, UQueryBuilder<T> builder2)
Parameters
Returns
Implicit(UQueryBuilder<T> to T)
Declaration
public static implicit operator T(UQueryBuilder<T> s)
Parameters
Returns
Inequality(UQueryBuilder<T>, UQueryBuilder<T>)
Declaration
public static bool operator !=(UQueryBuilder<T> builder1, UQueryBuilder<T> builder2)
Parameters
Returns