UI Button ON/Off

I am using the UI canvas, How do I get the object(monster) to turn off using the same button.

Register for Button click event and handle custom logic there:

class MyScript : Script
{
    public UIControl Button;
    public Actor Monster;

    /// <inheritdoc />
    public override void OnStart()
    {
        Button.Get<Button>().Clicked += OnClicked;
    }

    private void OnClicked()
    {
        Monster.IsActive = false;
    }
}

but when I click it again I want it to be active

Then do:

class MyScript : Script
{
    public UIControl Button;
    public Actor Monster;

    /// <inheritdoc />
    public override void OnStart()
    {
        Button.Get<Button>().Clicked += OnClicked;
    }

    private void OnClicked()
    {
        Monster.IsActive = !Monster.IsActive;
    }
}

Thanks this solved my problem