---
tags:
    - "Remove"
    - "Delete"
---

# On Destroy

[Component](index.md) / **On Destroy**

## Description

Executes when the game object or component attached is destroyed

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("On Destroy")]
    [Image(typeof(IconEmpty), ColorTheme.Type.TextLight)]
    
    [Description("Executes when the game object or component attached is destroyed")]
    [Category("Component/On Destroy")]
    
    [Keywords("Remove", "Delete")]

    [Serializable]
    public class TriggerCoreDestroy : Trigger
    {
        protected override string GetTitle(GameObject source) => "Destroy";

        protected override void OnDestroy()
        {
            base.OnDestroy();
            
            using Args args = Args.Get(this.Component, this.Component);
            this.Run(args);
        }
    }
}
```

