+2 votes

For some reason, buttons don't always seem to shrink to fit the text when using translations. Some buttons do, others don't, and I can't find any correlation between them.

For example, on the main menu scene there's this:

Main scene

While on the UI scene, there's this:

UI scene

The UI scene is then instanced into the main menu scene at runtime, and the result is this:

The game running

As you can see, the options button shrinks to fit the translation, but the new game/load game buttons don't. The same thing happens in other scenes, so it isn't an issue with instancing the UI.

I've also tried looking at the tscn files myself, and I see absolutely nothing different. In addition, copy-pasting the button from one tscn into another causes it to work, but doing more-or-less anything with it (moving it or connecting a signal) causes it to return to not shrink properly.

Am I doing something wrong? I've been at this for hours but haven't found anything.

in Engine by (26 points)

1 Answer

0 votes

It sounds like some people accomplish this by nesting each individual button in their own "CenterContainer" or "MarginContainer" which is responsible for their layout.

Unfortunately, it does not seem like Godot has any native solution for the "translation keys are very wide" problem. You have to roll your own by nesting your components in strange ways, or using an alternative solution such as GetText.

by (138 points)
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.