0 votes

So, I'm currently working on getting a simple menu set up with Godot. The basic structure of the Scene is having a Control node as root, with a VBoxContainer stores all the items in the scene. There is a label at the top of the list of children of VBoxContainer called Label, and then another VBoxContainer for the buttons (called buttons).

  • I have set the size flags for buttons to be unchecked all.
  • I then set the left margin of the buttons VBoxContainer to 96 (5% of the display) and it moves all the buttons over as expected.
  • I save the scene.
  • I tab away from the scene and tab back and the left margin is set to 0 again.

This is not the only place I've had this issue and it's not the only control that I'm having it with. Is there some sort of priority order of flags that I'm missing that would cause these values that I hard set to simply be ignored and reset to something else? I'm no expert with GUI design or with Godot, but my intuition tells me if I hard type a setting it should stick, not get overridden.

asked Dec 17, 2019 in Engine by sHerrmann (15 points)
edited Dec 17, 2019 by sHerrmann

"I then set the left margin to 96 (5% of the display)..."

Where are you doing this ?

Remember that containers determine the size and position of your children. In any case you can use an interleaved margin container. And then set the margin in the margin container, in custom constant

Sorry for the muddiness in the explanation! The margin for buttons (the second VBoxContainer) is where I'm setting left margin to 96. And I don't know if I understand the second part. Are you saying there's a node for margin that I can use as an item of the VBoxContainer to create the margin instead of actually setting it?

Edit: I did find the margin container. It is possible that this could work. But it would require a margin container for each button which, to me, sounds like a choppy workaround when I'm most likely missing something that should simply work. If need be I can grab screenshots or a demo that shows this problem.

I was thinking about something like this:

control
....marginContainer
........vBoxContainer
.............vBoxContainer
.................buttton1
.................buttton2
.............vBoxContainer
.................label

The left margin of the buttons should be aligned?

That actually does work. I'm not used to the whole "everything is a node" mentality so I just figured I could do this in as few nodes as possible...

Actually I'm still getting used to nodes as someone who worked in classes and structs >.<

Yes, I also have a hard time understanding it and there are still many things that I don't understand about Control nodes. But they cover most of the options and if something is missing you can make your own custom node. The important thing is to remember that when you use any control node of the container type, the position and margins of your children are controlled according to the properties of the container. These expand to cover the area of the container.

Please log in or register to answer this question.

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.