GameObjectExtensions.HasComponentInChildren

Extension Method in GameObjectExtensions

Declaration

public static bool HasComponentInChildren(this GameObject gameObject, Type component, 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.

Parameters

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

Returns

boolTrue if the component exists, false otherwise.