GameObjectExtensions.HasComponentInChildren<T>

Extension Method in GameObjectExtensions

Declaration

public static bool HasComponentInChildren<T>(this GameObject gameObject, bool includeInactive = false)

Description

Checks if the game object has a component of the specified type on itself or on any of its children using depth first search.

Type Parameters

TThe type of component to check for.

Parameters

gameObjectThe game object to check for the component.
includeInactiveIncludes inactive game objects.

Returns

boolTrue if the component exists, false otherwise.