Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force Godot to recalculate control nodes size/position?

Tags:

godot

Building UI in Godot 3.2.1. Of course I use anchors so UI elements are arranged within the screen automatically according to specified layout. I have UI scale system - nothing fancy - simply change font size (DynamicFont.size). If font size is large enough then some UI nodes may be pushed out of the screen. However, nodes don't return to normal sizes/positions with font size decreasing. The way to fix a mess is to resize game window which is not always an option and doesn't seem like a correct way to handle the issue. So how can I force Godot to recalculate control nodes size/position?

enter image description here


1 Answers

Changing the parent control's minimum size to Vector2(0, 0) after changing the font size might do the trick:

$Control.rect_min_size = Vector2(0, 0)

If it's already set to Vector2(0, 0), you may have to change it twice using call_deferred() for it to work.

like image 55
Calinou Avatar answered Oct 22 '25 06:10

Calinou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!