Skip to content

format

typescript
Component.gameObject

class: Component

description

(Read Only) The game object to which the current component is attached.

A game object is the basic building block in a scene, while a component is a functional module of a game object that contains its behavior and properties.

parameter

param_nametypedescription

reture

typedescription
GameObjectThe game object.

code example

typescript
let go = new GameObject();
// Add a BoxCollider component to the game object
let com = go.AddComponent<BoxCollider>(BoxCollider);
com.gameObject;