mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Node: Fix logic of has/get_node_and_resource and document it
Also document NodePath.
This commit is contained in:
@@ -268,6 +268,14 @@
|
||||
<argument index="0" name="path" type="NodePath">
|
||||
</argument>
|
||||
<description>
|
||||
Fetches a node and one of its resources as specified by the [NodePath]'s subname (e.g. [code]Area2D/CollisionShape2D:shape[/code]). If several nested resources are specified in the [NodePath], the last one will be fetched.
|
||||
The return value is an array of size 3: the first index points to the [Node] (or [code]null[/code] if not found), the second index points to the [Resource] (or [code]null[/code] if not found), and the third index is the remaining [NodePath], if any.
|
||||
For example, assuming that [code]Area2D/CollisionShape2D[/code] is a valid node and that its [code]shape[/code] property has been assigned a [RectangleShape2D] resource, one could have this kind of output:
|
||||
[codeblock]
|
||||
print(get_node_and_resource("Area2D/CollisionShape2D")) # [[CollisionShape2D:1161], Null, ]
|
||||
print(get_node_and_resource("Area2D/CollisionShape2D:shape")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], ]
|
||||
print(get_node_and_resource("Area2D/CollisionShape2D:shape:extents")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], :extents]
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_node_or_null" qualifiers="const">
|
||||
@@ -359,6 +367,7 @@
|
||||
<argument index="0" name="path" type="NodePath">
|
||||
</argument>
|
||||
<description>
|
||||
Returns [code]true[/code] if the [NodePath] points to a valid node and its subname points to a valid resource, e.g. [code]Area2D/CollisionShape2D:shape[/code]. Properties with a non-[Resource] type (e.g. nodes or primitive math types) are not considered resources.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_a_parent_of" qualifiers="const">
|
||||
|
||||
Reference in New Issue
Block a user