format
typescript
Component.instanceIDclass: Component
description
(Read Only) The instance ID of the object.
Every component created in the scene has a unique instance ID that can be used to identify and compare the uniqueness of components.
parameter
| param_name | type | description |
|---|
reture
| type | description |
|---|---|
number | The instance ID. |
code example
typescript
let go = new GameObject();
// Add a BoxCollider component to the game object
let com = go.AddComponent<BoxCollider>(BoxCollider);
com.instanceID;