When can I measure the rect of a control node?

Godot Version

4.3

Question

I want to get the rectangle of a control node as early as possible in a scene but when try to call get_rect in the _ready function it returns a Rect2 object where every value is 0, which I find a bit confusing.

So what would be the best way to call a function once everything is ready in a scene, including the control node rects?

I’m not confident what you need but,
You can use @onready:

@onready var sample_child := $Path/to/Node

func _read():
  # Now you can use it!

Hi.
the control nodes rect is updated on ready. _ready is called from the inside out, so every child has been ready before.

But control nodes do not stretch to enclose it’s children. So it stays zero unless you have set a specific height and width. For example, if you use a margin box or vbox, which stretches regarding to its children the get_rect will give you the total dimensions on ready.