How to detect if object is NOT colliding.

I have this code to display text when my space ship is colliding with another object, but I can’t figure out how to turn the text off if I’ve stopped colliding with the object.

Thanks for any help!

    public GameObject text;

    private void Start()
    {
        text.SetActive(false);
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject)
        {
            text.SetActive(true);
        }
    }

@Hawkeye91803 Just make sure to properly detect the specific objects you want to consider for collision enter and exit:

     public GameObject text;
 
     private void Start()
     {
         text.SetActive(false);
     }
 
     private void OnCollisionEnter(Collision collision)
     {
         if (collision.gameObject != null)
         {
             text.SetActive(true);
         }
     }

     private void OnCollisionExit(Collision collision)
     {
         text.SetActive(false);
     }