Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TryGetReference

Retrieves the VisualElement associated with the specified authoring ID path.
Read time 1 minuteLast updated 9 days ago

Definition

TryGetReference<T>(AuthoringIdPath, T)

Retrieves the VisualElement associated with the specified authoring ID path.
public bool TryGetReference<T>(AuthoringIdPath idPath, out T element) where T : VisualElement

Parameters

The authoring ID path to search for.

element

T
The element found at the given path. It's
null
if the element is no longer part of the hierarchy and has been destroyed.

Returns

Type

Description

bool
true
if the path was found; otherwise
false
.

TryGetReference<T>(DocumentNode, AuthoringIdPath, T)

Retrieves the VisualElement associated with the specified authoring Id path.
public bool TryGetReference<T>(VisualElementAssetReferenceTable.DocumentNode documentNode, AuthoringIdPath idPath, out T element) where T : VisualElement

Parameters

documentNode

The document node to search within. This allows searching for a path that is not based on the root.

The authoring ID path to search for.

element

T
The element found at the given path. It's
null
if the element is no longer part of the hierarchy and has been destroyed.

Returns

Type

Description

bool
true
if the path was found; otherwise
false
.