System.Action OnComponentDestroy { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The OnComponentDestroy property is an event handler that is invoked when a component is destroyed. This property allows you to specify a custom action to be executed at the moment the component is being destroyed. It is useful for cleanup operations or to trigger other actions that should occur when the component is no longer needed.

Usage

To use the OnComponentDestroy property, assign a method or lambda expression to it that defines the actions you want to perform when the component is destroyed. This can be done in the component's initialization or setup phase.

Example

// Example of using OnComponentDestroy
public class MyComponent : Component
{
    public MyComponent()
    {
        // Assign a lambda expression to OnComponentDestroy
        OnComponentDestroy = () =>
        {
            // Custom cleanup logic
            Log.Info("Component is being destroyed.");
        };
    }
}