Big Help: Container won't resize after move_child or MoveChild called

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

I am simply writing this to help anyone who comes across this bug. I wasted 2 days trying to figure this out.

Let’s say you have a container and it has different size controls in it. If you ever call container.move_child() or in C# container.MoveChild(), if this changes the size of the container, it will NOT resize on it’s own.

Some have suggested Hide() and then Show() the container, to refresh it, but this won’t work. Here is what I finally did that worked (This is in C#, use yield in GDScript):

container.MoveChild(5, 2);
await ToSignal(GetTree(),“idle_frame”);//SUPER TRICK.
container.RectSize = new Vector2(container.RectSize.x, 0);

On the next idle frame, Godot releases the old size and allows you to now change to a new size. In this case I am only changing the container’s y value. You can do what you want.

Hope this helps someone.

:bust_in_silhouette: Reply From: ondesic

Answer is included in the first post