Modifica

Condividi tramite


GameObjectExtensions.IsComponentRequired<T> Method

Definition

Checks if any MonoBehaviour on the given GameObject is using the RequireComponentAttribute requiring type T

public:
generic <typename T>
 where T : UnityEngine::Component[System::Runtime::CompilerServices::Extension]
 static bool IsComponentRequired(UnityEngine::GameObject ^ gameObject, [Runtime::InteropServices::Out] System::Collections::Generic::List<Type ^> ^ % requiringTypes);
public static bool IsComponentRequired<T> (this UnityEngine.GameObject gameObject, out System.Collections.Generic.List<Type> requiringTypes) where T : UnityEngine.Component;
static member IsComponentRequired : UnityEngine.GameObject * List -> bool (requires 'T :> UnityEngine.Component)
<Extension()>
Public Function IsComponentRequired(Of T As Component) (gameObject As GameObject, ByRef requiringTypes As List(Of Type)) As Boolean

Type Parameters

T

The potentially required component

Parameters

gameObject
UnityEngine.GameObject

the GameObject requiring the component

requiringTypes
List<Type>

A list of types that do require the component in question

Returns

true if T appears in any RequireComponentAttribute, otherwise false

Remarks

Only functions when called within a UNITY_EDITOR context. Outside of UNITY_EDITOR, always returns false

Applies to