Automatically Placing Child Nodes Inside a Parent Node

Godot Version

4.3.stable

Question

Hi everyone,

I’m working on a project in Godot 4, and I have a question about structuring scenes.

I’ve created a base scene called Page, which is structured like this:

-Control  
--Margin      (Container)
---Page       (VBox)
----Header    (HBox)
-----Title    (Label)  
-----Back     (Button)  
----Body      (Control)

Now, I want to use this Page scene as a base for other pages like “Options” or “Customization.” For example:

-Control  
--Page (instance of the `Page` scene)  
---[Custom UI for the page]

However, I want the custom components of each page to automatically appear inside the “Body” node of the Page instance.

I’d like this to work without needing to write code and to see the final structure directly in the editor (not just at runtime).

Currently, I can’t find a way to make the custom components automatically move under the Body node in the editor. Is there a way to achieve this using the editor’s tools, or should I restructure my scenes differently?

P.S. If you’re familiar with frameworks like Vue or React, I’m looking for something similar to a slot, where the custom content is automatically placed inside a specific part of the parent component

Thanks for your help!

I haven’t come across something like that. I tried to tinker around with the @tool scripts, but couldn’t figure it out and I can spend more time on it today unfortunately.

The easiest way to achieve this effect would be to make the children of your scene editable and put your nodes inside like that.


Hope that works for you.

I found a PR that solves this problem, it is being developed for version 4.4

1 Like