Hi All. I've just started playing with @tool feature. I'm trying to add nodes to an existing node in the editor. I assumed I could just use add_child() but nothing happened. I then discovered set_owner(get_tree().get_edited_scene_root()) which seemed to work, but not as clean as I was expected. I guess my question is does anyone have any references to explain what is going on under the hood, because reading the docs I'm still clueless.
#References for Modifying Scene Tree in Editor
1 messages · Page 1 of 1 (latest)
I think if the nodes are not "owned" by the root node of the scene file, they won't be serialized along with the rest of the nodes and they won't show up in the editor scene tree
Ok I think I get it then. It certainly points me in the right direction. Thanks for your help 🙂
The owner is the root node of the scene that the node belongs to, so either the scene tree root, or the root node of an instanced scene
If the node doesn't have an owner, it won't be saved in any scene
The editor usually sets the owner for you, and will hide nodes with no owner in the hierarchy
Nodes created in script never have an owner by default, you're always supposed to set it yourself, the difference just isn't usually noticable outside the editor