Skip to content

format

typescript
GameObject.GetComponent(type)

class: GameObject

description

Get the component on the game object by specifying the type of the component.

parameter

param_nametypedescription
typeComponentThe type of the component.

reture

typedescription
T|nullThe component.

code example

typescript
let go = new GameObject();
// Get the BoxCollider component on the game object
go.GetComponent(BoxCollider);