How to make sprite enable and disable when in a collider

Hello, I have this script here. I want to have a blue box appear when in a certain zone (in a collider) and dissapear when the player leaves it. However, it doesn’t ever seem to activate. Im not sure if its the code itself or how I have it in the hierarchy.


Basically I have an empty gameobject (TextControl) with a collider and a canvas inside. The collider is set to be a trigger meant to activate dialog1, but nothing seems to happen.

Heres the code, which is attached to dialog1

using UnityEngine;

public class TextToggle : MonoBehaviour
{
    public GameObject dialog1;

    void OnTriggerEnter(Collider other)
    { 
        if (dialog1.activeInHierarchy == false)
        {
            dialog1.SetActive(true);

        }
       
    }
    void OnTriggerExit(Collider other)
    {
        if (dialog1.activeInHierarchy == true)
        {
            dialog1.SetActive(false);

        }

    }
}

Any help would be much appreciated. EDIT: when adding a debug message, it seems that nothing is actually happening when I touch the box collider, Im not sure why…

FIXED!! Turns out I needed to put the code on the collider itself, not the dialog1