Skip to content

format

typescript
GameObject.DestroyComponent(com)

class: GameObject

description

Remove a component from a game object.

parameter

param_nametypedescription
comComponentThe component object to be removed.

return

typedescription
void

code example

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