기술 자료

Unity Engine

Unity Engine

GetComponentRefOrNullRef<T>()

Returns a reference to the component of type T attached to this element, or a null reference when the component is not attached. This method never adds a component.
읽는 시간 1분최근 업데이트: 22일 전

Definition

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

Returns

Type

Description

TA reference to the live component data, or a null reference when the component is not attached or this element's resources have been released. A valid reference stays valid until a component is added to or removed from this element.

Remarks

Always check the returned reference with
System.Runtime.CompilerServices.Unsafe.IsNullRef
before using it. Reading or writing through a null reference throws NullReferenceException. When the component is attached, this method behaves exactly like VisualElement.GetComponent.