How to prevent weird autoresizing of my UI elements ?

Hi all :slight_smile:

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 :

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

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.

I’ve found in the editor, that if I switch off of ‘Free Aspect’ to a defined ratio, this tends to go away.

Hello Leoslexus,

Thank you for having taken the time to answer my questions :smiley:

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 :smiley:

See you !