This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

An example pic
Is there a way to set horizontal alignment for elements in a Hboxcontainer in the editor? I played around with the settings in the editor, but could not find one to adjust the alignment. Could this been done by writing code in script file? Thank you.

in Engine by (266 points)

1 Answer

+2 votes
Best answer

It is not easier to just inject HBoxContainer inside other Control and then set Layout?
gif example

by (96 points)
selected by

Thank you for answering my question. I have played with the Layout options but seems it only works to adjust the HBoxContainer alignment to its parent node. I can not get it to work on its child nodes.

If I put another HBoxContainer (or other container in general) in side the a HBoxContainer, then the child node's Layout option is disable. Since all size and other position are disable for child nodes inside a HBoxContainer. I haven't find a way to adjust the alignment of the child nodes, so is that a way I could arrange the layout a child nodes, and get the child nodes of a HBoxContainer horizontally align.

A simple diagram for intended result

Hmm you can try wrap your Node with MarginContainer and adjust margin in Custom Constants like this:

MarginContainer inside HBoxContainer

I have tried to use a transparent png as a placeholder to add margins for child nodes, it worked. However, this is not very optimised solution to my problem. This way is much better, thank you for the tip. It would be even easier if the container has options to let user just play around with child node alignment, hope the new version will have some thing like that.

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.