Table of Contents

Method GetRequiredComponentInChildren

Namespace
Gamelogic.Extensions
Assembly
Gamelogic.Extensions.dll

GetRequiredComponentInChildren<T>(GameObject)

Gets a component of the given type in one of the children, or fail if no such component can be found.

public static T GetRequiredComponentInChildren<T>(this GameObject go) where T : Component

Parameters

go GameObject

The game object to check.

Returns

T

A component of type T attached to the given game object if it exists.

Type Parameters

T

The type of component to get.

Remarks

Use this method when you are sure that the component exists on the game object.

Exceptions

InvalidOperationException

no component of the required type exist on any of the given game object's children.