I really hope someone can help. This problem is completely show-stopping for me.
I'm creating nodes with new(), then adding them to the hierarchy with addchild(), then using setowner() after that.
However, the nodes never show up in the editor (hierarchy), no matter what I do.
I know that they are being created, because by using printtreepretty(), it shows them there.
Also, the created nodes are destroyed after the game is closed. They don't stay in the hierarchy.
Here's the link to download the example project so you can see for yourself:
(Press the "Enter" key to run the function that creates child nodes, then read the output for information. It will create a child every time you press "Enter".)
If you don't want to download that file, here's the code from the project.
(Sorry for the formatting.)
The hierarchy Looks likes this:
[Here's the Main node's script:]
var child_node : Node
const child_name : String = "Child"
var child_script : Script = preload("res://child_script.gd")
var holder_node : Node
const holder_name : String = "Holder"
child_node = Node.new()
child_node.name = child_name
holder_node = find_node(holder_name)
[Here's the child_node's script:]
var number_of_child_nodes : int
number_of_child_nodes = get_parent().get_child_count()
print("child_script was successfully attached to created child_node.")
print("number_of_child_nodes = " + str(number_of_child_nodes))