Why does my onTriggerEnter only fire once?

I am using the following code:

 void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.name == "Cube1")
        {
            Debug.Log("Cube 1");
        }
        if (other.gameObject.name == "Cube2")
        {
            Debug.Log("Cube 2");
        }
    }

When the object with the trigger touches Cube 1 I get the “Cube 1” message on the console log and when it touches Cube 1 I get the “Cube 2” message.

However I only get these messages one time. If my object triggers on cube 1 and then on cube 2 I never see any more messages if it goes back and touches cube 1.

Can someone explain why this is?

Check if that damned Collapse button is pressed in the Console view - when activated, it suppresses repeated messages, driving us crazy!

Debug.Log filter same Logs and show them once, so if you want to make sure your code works fine try

int _TriggerCounter = 0;
void OnTriggerEnter(Collider other)
{
    if (other.gameObject.name == "Cube1")
    {
         
         Debug.Log("Cube 1 " + (_TriggerCounter++).ToString() );
    }
    if (other.gameObject.name == "Cube2")
    {
         Debug.Log("Cube 2 " + (_TriggerCounter++).ToString());
    }
}