0 votes

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 .

asked May 16, 2019 in Engine by lowpolygon (164 points)
edited May 16, 2019 by lowpolygon

2 Answers

0 votes

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.

answered May 17, 2019 by Jowan-Spooner (758 points)

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.

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

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

0 votes

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).

answered May 15 by smbridges (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.