Collisions between UI elements in Unity

I am able to detect collision between UI components and a gameobject if my canvas is rendered in the world space. Here, I am trying to find collision between two UI elements (say UI buttons) when the canvas render mode is screen space overlay.

I added box collider components to my UI buttons and tried using OnCollisionEnter2D and OnTriggerEnter2D. But, the collision is not detected. Is there a way to detect the collision?

Collision detection between (box colliders attached to) UI Buttons work fine. Similar to 3D collisions, you need to make sure at least one of the components has a RigidBody2D attached. Also, you need to make sure your box colliders have the correct dimensions (simply copy the button dimensions).

If that doesn’t solve your problems, you should probably expand your question with some more details on what you are doing (code, etc).