On Destroy
The On Destroy event node is triggered when the object containing the script is destroyed.
Things you won't be able to do after an On Destroy:
- Get data from components within the destroyed object.
- Add Timed nodes such as Wait, Stop Watch as the script component will be destroyed when they process.
- On Update event won't process after.
Ports
Inputs
Port Name | Type | Default Value | Description |
---|---|---|---|
[Boolean] | True | If Enabled is set to true (Checked), the On Destroy event will be triggered when the object containing the script is destroyed. |
Outputs
Port Name | Type | Default Value | Description |
---|---|---|---|
Trigger | Execute next action after the GameObject is destroyed. |
Examples
In this example, we have a Cube containing a visual script that will:
Trigger the On Start event when entering play mode
- Wait 2 seconds.
- Destroy the game object Cube.
When the Cube get destroyed, the On Destroy event will be triggered.
- The message Destroyed will now be written in the console.