This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+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

in Engine by (101 points)
edited by

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.

by (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 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.