How to get a panel's margins position?

I’m a begginer in Unity and I’m trying to make a retro snake 2d game. I have 2 panels like this:


The smaller one is the field where the snake can move. I want to verify if the snake touches one of its borders. How can I do that?
P.S. Sorry for bad English

Do you really need two ui-panels ? Make dark one as sprite background and set 4 2D colliders as walls. And make snake based on physics2D.

Yes, but when the snake hits a wall i want it to apear from the opposite wall. But i think i found out how to do it. I can make a gameobject in code, assign it the panel from the editor and then get the position of the walls using the position and width and height

Or maybe not… I’m going to try with the colliders… :slight_smile:

But it does not appear on the screen when i press play. How can I make it a rectangle? And which collider should i use? The BoxCollider2D?

Try with 4* boxcollider2D set them to trigger. Check collision with OnTriggerEnter2D and replace snake with transform.position on other side. Snake should have rigidbody2d and collider2D.