0 votes

I'm writing a plugin that instances lots of user-made scenes and nodes and arranges them in the scene tree in the editor. When adding children to an already-instanced scene using code, it causes that scene's children to become visible in the scene tree panel, even though the Editable Children setting is disabled.

I've been adding children using <parent>.add_child(<scene or node>) and setting the owner to get_tree().edited_scene_root.

This is an example of a simple scene that might be instanced:
example instanced scene

This is what the scene tree looks like after my plugin builds the tree. The scene from the previous screenshot is instanced, and the Node3D is added as a child. note that the Sprite3D child node from the instanced scene is visable:
tree after building

This is an example of what I would expect the scene tree to look like after running the plugin. No instance children are visible, but multiple instances are parented to each other, along with a Node3D added at the bottom. I made this scene by manually instancing and dragging nodes in the editor to re-parent them:
manually parented scene

My question is: how can i replicate the same behavior i get from doing things manually using code? Have I missed something important, or am I doing things in the wrong way?

I've tested this in Godot 3.5.1 and 4.0 (beta 4), and the results are the same.

Thank you for your time!

in Engine by (12 points)
edited by

Have you ever got to the bottom of this? I'm looking for something similar

Please log in or register to answer this question.

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.