UI do not stay in size

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lowpolygon

I just created a UI panel, and used the layout button to fill the whole viewport. Then I saved it . When it drag it to another scene, it shrink back to whatever it was instead of fill whole screen thing when it was saved. Is there a apply button or something that keeps the size?
It happened sometimes to buttons and box container as well. I am not sure what I did wrong

Edit: Did more digging, I found that if I set min size in rect it will keep the size .

:bust_in_silhouette: Reply From: Jowan-Spooner

Keep in mind that the filling/size of the control nodes is relative to their parent ones. If a control node is the root of your scene it will use the viewports size but if it’s child of any other control node, everything will be different. Therefore are anchors and margins, that will change the behaviour.

Anchors specify to which corner/edge of the parent node the own position and size are relative to. Margins create a gap between the parent this point and the node. All of this is mainly made for easy window resizing in a way that some ui elements stay always in the bottom left corner or just a little below the centre of the screen. Have you seen this tutorial of GDquest? Or if reading works better for you the documentation about Size and anchors and the step by step about building a responsive gui are pretty good.

Hope I was able to help.

Unfortunately, it is not the case for me. You see, all I have in the UI scene is just a panel.
And the new scene I dragged the UI into has nothing. As for viewport size , it is the same between the ui scene and the test scene.

lowpolygon | 2019-05-18 00:00

I’m sorry that it did not help.
How do you ‘drag’ your panel to the new scene?

Jowan-Spooner | 2019-05-19 20:56

I drag it from file system window to scene window,and place it directly under root node

lowpolygon | 2019-05-20 01:38

:bust_in_silhouette: Reply From: smbridges

As mentioned in other answers, the cause is related to which parent the UI scene is instanced under. For example, a Node2D parent does not provide the desired behavior.

The Design the GUI tutorial uses a parent type of Node, which will behave as desired. Another option is to create a CanvasLayer for the control nodes to live under (as seen in the Godot OpenRPG project).