Why is OnTriggerExit not firing?

I want to detect if an enemy is inside a spotlight’s range.

I have a Spotlight that has a cone mesh as a child. The cone is a trigger and I disable and enable it with the spacebar when the light is turned on or off.

I’ve set up the enemy code to be something like the following pseudocode:

    OnTriggerEnter(other){
        if(other == ConeMesh)
            ReduceHitPoints();
    }
    
    OnTriggerExit(other){
       if(other == ConeMesh)
           IncreaseHitPoints();
    }

The OnTriggerEnter part works great; however, the OnTriggerExit is not firing.

Let’s say that the enemy is in the dark and you shine the light. This enables the cone’s collider, it calls the enemy’s OnTriggerEnter and the enemy’s health is reduced. The enemy is now inside the light and I decide to turn it off. The light goes off, the cone’s collider is disabled but OnTriggerExit is NOT called. Why?

If your collider is disabled, how can it detect if it’s in light or not?

Since this is a top result on Google I wanted to link to a more robust solution
https://forum.unity.com/threads/fix-ontriggerexit-will-now-be-called-for-disabled-gameobjects-colliders.657205/

Because, from your description, the cone collider never exits the trigger… it is disabled while it is inside the trigger. A disabled collider, by definition, doesn’t fire any OnTrigger events.