UnityObjectExtensions.TryGetMonoBehaviour<T>(T, MonoBehaviour) Method

Definition

Properly checks an interface for null and returns the MonoBehaviour implementing it.

public:
generic <typename T>
 where T : class[System::Runtime::CompilerServices::Extension]
 static bool TryGetMonoBehaviour(T interface, [Runtime::InteropServices::Out] UnityEngine::MonoBehaviour ^ % monoBehaviour);
public static bool TryGetMonoBehaviour<T> (this T interface, out UnityEngine.MonoBehaviour monoBehaviour) where T : class;
static member TryGetMonoBehaviour : 'T * MonoBehaviour -> bool (requires 'T : null)
<Extension()>
Public Function TryGetMonoBehaviour(Of T As Class) (interface As T, ByRef monoBehaviour As MonoBehaviour) As Boolean

Type Parameters

T

Parameters

interface
T
monoBehaviour
UnityEngine.MonoBehaviour

Returns

True if the implementer of the interface is a MonoBehaviour and the MonoBehaviour is not null.

Applies to