BoxContainer ignores scale property of children

Godot Version

v4.2.1

Question

I want to add textured buttons to a HBoxContainer through script. But changes to the scale property of the button are ignored. How can I make it respect the change of scale?

var button = TextureButton.new()
var my_texture = load("res://some_texture.svg")
button.texture_normal = my_texture
button.scale = Vector2(0.1,0.1)			
$ScrollContainer/HBoxContainer.add_child(button)

Containers set the position of its children and reset the scale and rotation. You can’t scale a Control node inside a Container.

If you still want to scale the button then you’ll need to use a Control node as its parent and modify that Control node Control.custom_minimum_size to some value.

1 Like

Thanks that worked :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.