Displaced UI RectTransform collider in some resolutions issue.

Hello.

I’m creating custom UI buttons for my game using UI Images. I’m using C# scripts that provides IPointerHandler to detect when the mouse is over, clicking and exiting. When I builded the game, in some resolutions I have the following problem with the mouse on Rect Transform collision:

Normal Resolution (works perfect):

48476-normalres.png

Another Resolutions. As you can see below the RectTransform is displaced to left.

48477-lowres.png

Somehow in some resolutions the RectTransform collision is displaced. I don’t know why. Why this happens? How I can solve this problem? I want that RectTransform colliders works perfect in all possible resolutions.

Maybe I’m too late, but I’ll answer it just in case someone else comes to here in need of help:

Here you can read information about how the screens resolutions and the anchors of the UI works.

https://docs.unity3d.com/Manual/HOWTO-UIMultiResolution.html

As an important note, be aware that you probably want to set the anchor and NOT the Pivot. In my case I was making a mobile phone, and the layout joystic was moving strangely. I had to put the Anchor in one corner, and the pivot on the center of the screen, to make it pivot correctly, and not around a point in a corner.

I hope this helps someone ^^