Table of Contents

Method GetRequiredComponent

Namespace
Gamelogic.Extensions
Assembly
Gamelogic.Extensions.dll

GetRequiredComponent<T>(GameObject)

Gets a component of the given type on the game object, or fail if no such component can be found.

public static T GetRequiredComponent<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 the given game object.