瀏覽代碼

Merge pull request #34747 from rcorre/add_child_owner

Add note about add_child and owner.
Rémi Verschelde 5 年之前
父節點
當前提交
32fd350254
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      doc/classes/Node.xml

+ 1 - 0
doc/classes/Node.xml

@@ -129,6 +129,7 @@
 				    child_node.get_parent().remove_child(child_node)
 				add_child(child_node)
 				[/codeblock]
+				[b]Note:[/b] If you want a child to be persisted to a [PackedScene], you must set [member owner] in addition to calling [method add_child]. This is typically relevant for [url=https://godot.readthedocs.io/en/latest/tutorials/misc/running_code_in_the_editor.html]tool scripts[/url] and [url=https://godot.readthedocs.io/en/latest/tutorials/plugins/editor/index.html]editor plugins[/url]. If [method add_child] is called without setting [member owner], the newly added [Node] will not be visible in the scene tree, though it will be visible in the 2D/3D view.
 			</description>
 		</method>
 		<method name="add_child_below_node">