format
typescript
GameObject.AddComponent(type)class: GameObject
description
根据组件类型为当前游戏对象添加组件。
parameter
| param_name | type | description |
|---|---|---|
| type | Component | 组件类型 |
reture
| type | description |
|---|---|
T|null | 添加的组件 |
code example
typescript
let go = new GameObject();
//为游戏对象添加一个BoxCollider组件
let com = go.AddComponent<BoxCollider>(BoxCollider);