Godot Version
4.4.1 Stable
I did my homework and thoroughly read the documentation on how Control nodes, anchors, and anchor offsets work. In the docs, everything seems clear and logical. And yet, I’m struggling with a relatively simple task: displaying a logo in the center of the game’s title screen.
Here is my setup:
The title screen is a separate scene. It contains only four elements: a background image, a logo image, menu buttons, and a version number label.
The scene tree is as follows:
MainMenuUI (Control node; Anchors preset: FullRect)
├── Background (TextureRect)
├── MainContainer (VBoxContainer; Anchors preset: left 0.1, right 0.9, top 0, bottom 1.0)
│ ├── Logo (TextureRect)
│ ├── MenuButtons (VBoxContainer)
│ │ ├── Button1, etc.
│ └── VersionNumber (Label)
The base resolution for the game is set to 1920×1080.
The general idea is to have all elements centered on the screen: the logo at the top, followed by four buttons, and finally the version number (which is right-aligned — that part is working fine). A VBoxContainer seemed like the perfect fit here because it automatically stacks child nodes vertically, and spacing is easy to manage using the separation property.
As you can see, the MainContainer node has 10% margins on the left and right. It also has its Alignment set to Center, although that might not be necessary since the child nodes use the Shrink Center size flag (I haven’t noticed any difference, but I set all of them to center just in case).
Now, the issue: I’m struggling with the logo. I’m testing with a large logo (3000 px wide) to ensure it won’t get upscaled on higher resolutions (we can set aside pixel-perfect concerns for now — this is just for testing). Given that:
- The logo’s TextureRect Expand Mode is set to Keep Size (the default), and
- No minimum width/height is set
The logo overflows beyond the borders of MainContainer. The only way I’ve managed to shrink it is by:
a) setting Expand Mode to Ignore, and
b) defining a minimum size for width and height — otherwise, the logo collapses into a singularity and isn’t visible at all.
So my question is:
Is this the only viable method to keep the logo constrained within the desired bounds, assuming I want it to remain part of the VBoxContainer?
Any help would be much appreciated!