+2 votes

I am setting the rect_scale of my Label to (0.5, 0.5) and then launching the scene, but after launch the scale is reset back to (1, 1)

Anyone have an idea how this can be overcome?

Steps to reproduce

  • Create a new scene
  • Make the root node a VBoxContainer
  • Add a Label as child
  • Set Label text to "My label text"
  • Set Label scale to (0.5, 0.5)
  • Run scene
  • Notice that Label's scale is (1, 1) and not (0.5, 0.5)

Godot v3.1.2

asked Jan 21 in Engine by CKO (86 points)
edited Jan 21 by CKO

More details, please.
Where (in terms of code/event) do you exactly set the scale of the label. And to what variable.
How do you exactly "launch" that scene? Via change_scene?

My impression is that you change the label scale in another instance of the scene.

  • Create a new scene
  • Make the root node a VBoxContainer
  • Add a Label as child
  • Set Label text to "My label text"
  • Set Label scale to (0.5, 0.5)
  • Run scene
  • Notice that Label's scale is (1, 1) and not (0.5, 0.5)

It looks like all the container controls in Godot reset the scale of their children to their own scale, which means you can't have a child control with a different scale than it's parent if the parent is a container node.

The solution is ugly: use a parent that doesn't reset the scale of it's children. For example, a Panel node seems to behave well in that regard.

Yes, it seems that container take certain control about position and size of their childs. While some behaviour could be controlled via the size flags the scale is reset to 1,1 (found this in the containers source in fit_child_in_rect().

In your case: Couldn't you just change the font size of your label to make it smaller?

From this post: https://godotengine.org/qa/3335/label-text-size, I understand that I would need to import a custom font in order to resize the font. Is this correct or is there a way to resize the default font in Godot?

1 Answer

0 votes

Right so the VBoxContainer doesn't allow a child to have a different scale factor and your stuck using the factor of the parent container... BUT if I'm not mistaken there isn't a way to change the scale factor of a VBoxContainer... so what the f.

answered Jul 30 by ArmouredMongol (14 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 How to use this Q&A? before posting your first questions.