Scale value of Label reset upon launch

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CKO

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

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.

wombatstampede | 2020-01-21 14:25

  • 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)

CKO | 2020-01-21 17:21

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.

CKO | 2020-01-21 17:34

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?

wombatstampede | 2020-01-22 07:40

From this post: https://forum.godotengine.org/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?

CKO | 2020-01-24 04:14

:bust_in_silhouette: Reply From: ArmouredMongol

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.