Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetComponent<T>()

Returns a reference to the attached component of type T.
Read time 1 minuteLast updated 7 days ago

Definition

public ref T GetComponent<T>() where T : struct, IVisualElementComponent

Returns

Type

Description

TA reference to the live component data.

Remarks

The reference points at the component's live storage: assigning to its fields updates the element directly, with no need to write the value back. The reference stays valid until the component is removed.