The container control of Godot uses the size of the child nodes to arrange, but does not use the scale attribute. This node will use the scale and size attributes to calculate the actual size of the child nodes, and then automatically set min_size to arrange.
-
Copy
addons/fit-size
into your project (final path should beres://addons/fit-size
). -
In the Godot Editor, go to Project Settings > Plugins and enable the FitSize plugin.
To be fit in size, a Control node must be child of a FitSize.
- From the editor, press Add a new node, and select FitSize
Note: to add the Container from script, you must use this code:
var FitSize = preload("res://addons/fit-size/main.gd")
add_child(FitSize.new())
-
Add any Control node as a child of FitSize.
-
You can set the size of child or the scale of child, then the min_size of FitSize will be change.