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:

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:

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:

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!