r/UnityHelp • u/NimuKnight • Dec 02 '22
Resizing Elements For Differing Resolutions
Hi all,
I'm trying to make a small mobile application for my friends and I to use, but I'm running into an issue with resizing elements for different resolutions. I've tried looking it up, but nothing I have found has helped.
When on my phone's resolution, this UI element is in the correct position with the correct dimensions:

However, when I change the resolution to something much shorter, the UI element is still in the correct location, but the dimensions get thrown off, and even expand off of the canvas:

I've tried anchoring them to their respective corners and limiting their min and max anchors, but they seem to break out of those set boundaries whenever the screen is resized and I can't figure out why. If anybody happens to know a way to fix this, the help would be greatly appreciated!
Thanks!
Also, I know some of the other stuff also gets funky, but that's because I haven't properly set them up to resize since it wasn't working properly with these other elements first.
1
u/corrtex-games Dec 02 '22
I believe you want a CanvasScaler component on your canvas. Then choose “scales with screen size” and input the dimensions of the screen that your main layout is targeting