Scale with Screen Size and Maximize on Play

My Canvas Scaling is configured with “Scale with Screen Size” with reference resolution at 800 x 450. When I hit play, and then resize the game window or even maximize it, my widgets scale beautifully to support the larger resolution. If, however, I select “Maximize on Play” and hit play, my widgets are assuming the layout min width and height, as opposed to scaling up.

Any ideas?

The answer to this horrible scenario is related to reparenting. My widgets were dynamically created (prefabs) and were using setParent() to place themselves. As the canvas was being “scaled” up, the reparenting was inverting the canvas scale to maintain original size.

TLDR: setParent() needs worldPositionStays = false when using “Scale with Screen Size”.

I have the same problem but your solution doesn’t work for me. The size of the objects is right, but the positions don’t scale well when using Maximize on Play. I have the following structure on my Hierarchy:


126647-screenshot-20181024-224724.png


The problem comes when I try to clone StartBuildButton like this:


Instantiate(button, button.transform.position + Vector3.down * 30, Quaternion.identity, viewportContent);

I also tried using SetParent(viewportContent, false) and then setting the position.

If I use Maximize on Play, it looks like this:



I can’t provide more attachments, but I can say that when I press the Play button and then maximize the game window, it looks nice.