Making a textbox that scales with screen size

Godot Version

4.2.2.stable

Question

Howdy! I have a working textbox using margin containers, a nine-slice rectangle, and a label. The only problem is, when I fullscreen the game, the size and position of the textbox and text remains the same. How do I get the textbox to scale properly with the rest of the screen?
Here’s what the textbox looks like in the editor and how much of the screen it should take up.


Here’s what the textbox looks like after I fullscreen the game.

Thank you in advance for your helpful insight, I appreciate it!

Go to project → project settings → display → window → stretch and change mode to viewport

Thank you! This was exactly what I needed, although the text becomes a little bit blurry as it stretches from it’s original size. Is that because of anti-aliasing and is there a way to disable that? Or is it an issue of resolutions?

Change the text boxes anchors (green arrows) instead of the size (red dots). It’s a little to get used to but the anchors let you specify how the controls scales in a multitude of ways.

Best to try out these options, “Full Rect” for instance will always scale the text box to be relative to the screen size. “HCenter Wide” will center the text box, and grow it to the screen’s width. You can adjust the size (red dots) after setting the anchors.

2024-07-28-202849_3840x1080_scrot

1 Like

Thank you! This works great as well, I just had to use “Set to Current Ratio” to get the anchors in the right spot, but the text’s size isn’t expanding at all so it gets proportionally smaller when I stretch out the textbox.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.