This project is in a trial period, be cautious while contributing. Setup can still change before being approved as a libre project.
Loading…
None
String added in the repository |
Loading…
None
String added in the repository |
[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://docs.rebeltoolbox.com/en/latest/tutorials/misc/running_code_in_the_editor.html]tool scripts[/url] and [url=https://docs.rebeltoolbox.com/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.
如果[code]legible_unique_name[/code]是[code]true[/code],子节点将有一个基于被实例化的节点的名称,而不是其类型可读的名称。
[b]注意:[/b] 如果子节点已经有父节点,该函数将失败。首先使用[method remove_child]将节点从其当前的父节点中移除。如:
[codeblock]
if child_node.get_parent():
child_node.get_parent().remove_child(child_node)
add_child(child_node)
[/codeblock]
[b]注意:[/b] 如果你想让一个子节点被持久化到[PackedScene]中,除了调用[method add_child]外,还必须设置[member owner]。这通常与[url=https://godot.readthedocs.io/en/3.2/tutorials/misc/running_code_in_the_editor.html]工具脚本[/url]和[url=https://godot.readthedocs.io/en/latest/tutorials/plugins/editor/index.html]编辑器插件[/url]有关。如果调用[method add_child]而不设置[member owner],新添加的[Node]在场景树中是不可见的,尽管它在2D/3D视图中可见。