#References for Modifying Scene Tree in Editor

1 messages · Page 1 of 1 (latest)

wooden needle
#

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.

scenic mist
wooden needle
#

Ok I think I get it then. It certainly points me in the right direction. Thanks for your help 🙂

glacial knoll
#

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