System.Action OnComponentDisabled { get; set; }

robot_2Generated
code_blocksInput

Description

The OnComponentDisabled property is an event handler that is triggered when a component is disabled. This property allows you to define custom actions that should occur when the component's enabled state changes to false.

Usage

To use the OnComponentDisabled property, assign a method or lambda expression to it that defines the actions to be performed when the component is disabled. This can be useful for cleaning up resources, stopping animations, or other tasks that should occur when a component is no longer active.

Example

// Example of using OnComponentDisabled
public class MyComponent : Component
{
    public MyComponent()
    {
        OnComponentDisabled = HandleComponentDisabled;
    }

    private void HandleComponentDisabled()
    {
        // Custom logic to execute when the component is disabled
        // For example, stop a sound or animation
        StopSound();
    }

    private void StopSound()
    {
        // Implementation to stop sound
    }
}