0 votes

I have a scene which draws some stuff to the canvas, and under certain conditions "pops up" an instanced scene on one part of the canvas. So something like:

Root Node
|-> sprites etc.
|-> Instanced Scene "pane"
      |-> labels, buttons, etc.

When I instance the pane, it appears at the full dimensions and positions of the original, while I would like it to only cover e.g. the left third of the screen, and all the children of the pane to reposition accordingly. I can do this manually by fussing with positions in pane._ready, but that's not scalable as the pane grows in detail (gets more children).

I don't want to make the instanced pane a static child of the root because I might have multiple different panes shown at different times, and editing them all in one scene would be very difficult.

How can I get the instanced scene to resize/reposition its children when I instance it?

Godot version 3.4.2
in Engine by (15 points)

1 Answer

+1 vote
Best answer

If the instanced scene is a Control node, then you can use rectsize and rectmin_size properties, and margins and such. If your node heirerarchy is structured right all the children will adjust the right way when you realize the top node.

You can also the use the scale property, but they comes with other challenges, unless you're just uniformly resizing

If it's not a Control node, but a node2d type node, then you have to use scale I think

by (1,290 points)
selected by

The way to structure it is using anchors and margins... This tutorial might help ya:

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.