How to prevent weird autoresizing of my UI elements ?
Hi all :)
I'm relatively new on Unity, I'm following a tutorial in order to create a point and click game and so far everything is going smoothly. Well... "was" going smoothly :x
See, I've encountered a problem while implementing the UI elements in my game : the game preview shows my panels are nicely sized, but as soon as I click "Play" they resize and appear way bigger than I intended. Worse, if I mess with the window's size, then click pause, then go back to the Scene : it appears the size of my UI elements HAS changed. Without my input in the scene. Spooky oO
All my UI elements are on the UI layer.
The Canvas is set to Screen Space - Overlay.
Here are three captures if it helps : https://ibb.co/d7Lg6w https://ibb.co/n7gomw https://ibb.co/e3t16w
I guess there's an option somewhere that enables that weird autoresizing but for the life of me I can't seem to find it alone...
Thanks in advance for your help and suggestions :o
Best regards
Answer by LeeXxE · Jan 24, 2018 at 01:48 AM
Go to canvas then in the inspector you should notice in the canvas scaler section ''Constant Pixel size", just change it with ''Scale with screen size'' and voila.. Should fix your issue.
Answer by davelance · Feb 03, 2020 at 09:46 PM
I've found in the editor, that if I switch off of 'Free Aspect' to a defined ratio, this tends to go away.
Answer by unity_ZF0JwnL6OjmkLA · Jan 24, 2018 at 11:39 AM
Hello Leoslexus,
Thank you for having taken the time to answer my questions :D
In the Canvas Scaler I went with the Scale with Screen Size and it partially solved the problem. The width was fine but the height was still bigger than expected. I then changed the "resolution" right beneath the previous option to 1600x900 instead of the default 800x600 and it looks much better on my screen now !
Still, the resizing was a little awkward when I manually manipulated the size of my window, so I eventually chose "Screen Match Mode : Match Width of Height", set it to 1, played with the anchors of some objects, and now I'm satisfied with how my UI behaves.
Long story short : you unblocked me, thanks a lot :D
See you !
Your answer

Follow this Question
Related Questions
Canvas help? 0 Answers
IMAGE AND SPRITE SETTINGS 0 Answers
iPhone 5/6 and 6Plus 0 Answers
UI does not work in build 0 Answers