diff --git a/tutorials/scripting/img/unique_name.png b/tutorials/scripting/img/unique_name.png index 4325dd4be4c..bcbdcc9cbea 100644 Binary files a/tutorials/scripting/img/unique_name.png and b/tutorials/scripting/img/unique_name.png differ diff --git a/tutorials/scripting/img/unique_name_scene_instance_example.png b/tutorials/scripting/img/unique_name_scene_instance_example.png new file mode 100644 index 00000000000..3d5145ab7a4 Binary files /dev/null and b/tutorials/scripting/img/unique_name_scene_instance_example.png differ diff --git a/tutorials/scripting/scene_unique_nodes.rst b/tutorials/scripting/scene_unique_nodes.rst index ec224d5f191..b7cd2d0333e 100644 --- a/tutorials/scripting/scene_unique_nodes.rst +++ b/tutorials/scripting/scene_unique_nodes.rst @@ -6,30 +6,31 @@ Scene Unique Nodes Introduction ------------ -There are times in a project where a node needs to be called -from a script. However, its position in the tree might change -over time as adjustments are made to a scene, such as a -button in a UI scene. +Using ``get_node()`` to reference nodes from a script can sometimes be fragile. +If you move a button in a UI scene from one panel to another, the button's node +path changes, and if a script uses ``get_node()`` with a hard-coded node path, +the script will not be able to find the button anymore. -In situations like this, a node can be turned into a scene -unique node to avoid having to update a script every time -its path is changed. +In situations like this, the node can be turned into a scene +unique node to avoid having to update the script every time +the node's path is changed. -Creating and using them ------------------------ +Creation and usage +------------------ In the Scene tree dock, right-click on a node and select -**Access as Scene Unique Name** in the context menu. +**Access as Unique Name** in the context menu. .. image:: img/unique_name.png -After checking this, the node will now have a percent symbol (**%**) next +After selecting the option, the node will now have a percent symbol (**%**) next to its name in the scene tree: .. image:: img/percent.png -To use a unique node in a script, use the ``%`` symbol and the node's -name in the path for ``get_node()``. For example: +You can now use the node in your script. For example, you can reference it with +a ``get_node()`` method call by typing the % symbol, followed by the node's +name: .. tabs:: @@ -41,3 +42,57 @@ name in the path for ``get_node()``. For example: .. code-tab:: csharp GetNode