From d4d03e5de9189d2c81a19a40362b8c23f9a8893f Mon Sep 17 00:00:00 2001
From: zzwx <8169082+zzwx@users.noreply.github.com>
Date: Wed, 14 Aug 2019 10:40:00 -0400
Subject: [PATCH] Documentation note that Node::add_child() fails if child
already has a parent
---
doc/classes/Node.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index 889ce4d3eb7..097fa1f6e54 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -122,6 +122,12 @@
Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.
If [code]legible_unique_name[/code] is [code]true[/code], the child node will have an human-readable name based on the name of the node being instanced instead of its type.
+ [b]Note:[/b] If the child node already has a parent, the function will fail. Use [method remove_child] first to remove the node from its current parent. For example:
+ [codeblock]
+ if child_node.get_parent():
+ child_node.get_parent().remove_child(child_node)
+ add_child(child_node)
+ [/codeblock]