Open miv391 opened 1 week ago
This is an expected behaviour.
If the Control node is a child of a Container node, the scale will be reset to Vector2(1, 1) when the scene is instantiated. To set the Control's scale when it's instantiated, wait for one frame using await get_tree().process_frame then set its scale property.
EDIT: The real issue is that, after creating label_2 node in MRP , it resets label node's scale to Vector2(1,1) even if you use await in start of function.
@miv391 update your ready function like this, this will work until you un-comment label_2 code.
func _ready() -> void:
# this does work:
await get_tree().process_frame
label.scale = Vector2(0.4, 1.0)
#label_2 = Label.new()
#v_box_container.add_child(label_2)
#label_2.text = "Another label with some text"
# this doesn't work:
#label_2.scale = Vector2(1.0, 2.0)
I have to admit I didn't read documentation about how scale
works with containers. In debug mode it could be nice if a warning were displayed if non-Vector(1,1)
scale
value is reset because of the container.
Tested versions
System information
v4.4.dev3.mono.official [f4af8201b]
Issue description
When control node is contained by a container (eg.
VBoxContainer
) and its scale is set immediately after node's creation, the scale value doesn't have any effect. If the scale is set afterwards or it is set using a tween with 0 second duration, the scale works as expected.Steps to reproduce
Scene:
Code:
If the button is clicked or if the two
create_tween()
lines are uncommented, scales are working as expected.Minimal reproduction project (MRP)
scale_test.zip