how to instance node from a editor plugin

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By godisntheradio

I am trying to make an plugin that automatically adds nodes to a batch of nodes

for block in get_tree().get_edited_scene_root().get_children():
		var tile =

the problem is, this code creates the node but does’t appear in the tree in the editor. In addition to that, if i close this scene that had nodes instanced by my editor plugin, it won’t save the instanced nodes.

unless i misunderstood something about editor plugins, i should have been able to instance node from an plugin right? if yes, is there an addional procedure besides new add_child ?

:bust_in_silhouette: Reply From: wombatstampede

First: I think setting a name for the new node would be a good idea.

You need to set the owner of the new node (to the scene) after adding it.

No owner is the reason why it isn’t visible/saved.

thanks! i was trying to create nodes to reparent existing one’s, the problem was i was setting the owner of the existing one’s and forgot about the one i just created, so everything disappeared from the tree. again thanks!

godisntheradio | 2019-04-18 23:55