0 votes

I made a form with controls (buttons, line editors...) and I want to center it in my screen. I tried to create a Container control with a fixed size and to put all my elements in this container. And then I set the layout of the container to centered full height, but it aligns my container as if it didn't have any width:

I use only controls, so there's always a width and height. How to force godot to align my container on its true center?

in Engine by (697 points)

1 Answer

0 votes

You can use a center container and set the archor property too FullRect. And if you haven't, also use VBoxContainer and HBoxContainer to align items in your form, those containers are very useful.

Here is a video explaining this in more detail:

by (21 points)

Interesting indeed. But I also found another way, maybe a bit easier. If I manually correct the offset after I aligned the container, it is taken in account when the window is resized. With some try and error I could find the right offset to keep my container centered.

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.
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 webmaster@godotengine.org with your username.