From 54d6c9e83b4cdfa59095693d4585f838f3976978 Mon Sep 17 00:00:00 2001 From: Hakim Date: Wed, 3 Jul 2024 11:56:31 +0200 Subject: [PATCH] Add : to node properties, to differentiate them from node paths --- doc/classes/NodePath.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/classes/NodePath.xml b/doc/classes/NodePath.xml index b4969b8906d9..d0ec81ab4549 100644 --- a/doc/classes/NodePath.xml +++ b/doc/classes/NodePath.xml @@ -23,11 +23,12 @@ [/codeblock] Despite their name, node paths may also point to a property: [codeblock] - ^"position" # Points to this object's position. - ^"position:x" # Points to this object's position in the x axis. + ^":position" # Points to this object's position. + ^":position:x" # Points to this object's position in the x axis. ^"Camera3D:rotation:y" # Points to the child Camera3D and its y rotation. ^"/root:size:x" # Points to the root Window and its width. [/codeblock] + In some situations, it's possible to omit the leading [code]:[/code] when pointing to an object's property. As an example, this is the case with [method Object.set_indexed] and [method Tween.tween_property], as those methods call [method NodePath.get_as_property_path] under the hood. However, it's generally recommended to keep the [code]:[/code] prefix. Node paths cannot check whether they are valid and may point to nodes or properties that do not exist. Their meaning depends entirely on the context in which they're used. You usually do not have to worry about the [NodePath] type, as strings are automatically converted to the type when necessary. There are still times when defining node paths is useful. For example, exported [NodePath] properties allow you to easily select any node within the currently edited scene. They are also automatically updated when moving, renaming or deleting nodes in the scene tree editor. See also [annotation @GDScript.@export_node_path]. See also [StringName], which is a similar type designed for optimized strings.