Bearbeiten

Freigeben über


GameObjectExtensions.FindAncestorComponent<T> Method

Definition

Find the first component of type T in the ancestors of the specified game object.

public static T FindAncestorComponent<T> (this UnityEngine.GameObject gameObject, bool includeSelf = true) where T : UnityEngine.Component;
static member FindAncestorComponent : UnityEngine.GameObject * bool -> 'T (requires 'T :> UnityEngine.Component)
<Extension()>
Public Function FindAncestorComponent(Of T As Component) (gameObject As GameObject, Optional includeSelf As Boolean = true) As T

Type Parameters

T

Type of component to find.

Parameters

gameObject
UnityEngine.GameObject

Game object for which ancestors must be considered.

includeSelf
Boolean

Indicates whether the specified game object should be included.

Returns

T

The component of type T. Null if it none was found.

Applies to