GetFirstChild Method

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

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

Declaration
public static TElement GetFirstChild<TElement>(this VisualElement ve, Func<TElement, bool> filter = null)
    where TElement : VisualElement
Parameters
VisualElement ve

The parent element

Func<TElement, Boolean> filter

An optional filter callback

Returns
TElement

A child that satisfies conditions or null.

Type Parameters
TElement

The type of the child

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

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

Declaration
public static TElement GetFirstChild<TElement>(this VisualElement.Hierarchy hierarchy, Func<TElement, bool> filter = null)
    where TElement : VisualElement
Parameters
VisualElement.Hierarchy hierarchy

The parent element

Func<TElement, Boolean> filter

An optional filter callback

Returns
TElement

A child that satisfies conditions or null.

Type Parameters
TElement

The type of the child