mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-09 09:29:06 +00:00
- `_Process` and `_PhysicsProcess` take their delta argument as a `double` - Use string interpolation instead of concatenating strings - Use `string` instead of `String` (`using System` was removed from everywhere in a previous PR) - Use `System.Array.Empty<T>()` to init empty arrays - Use `SignalName.*` instead of `nameof(*)` for signals - Do not use `event` as an argument name (that's a keyword) - Match node paths to screenshots when retrieving nodes from the tree - Add a C# example for scene unique nodes - Update the "Cross language scripting" page - Add a note about using `is` against `null`
43 lines
1.0 KiB
ReStructuredText
43 lines
1.0 KiB
ReStructuredText
.. _doc_scene_unique_nodes:
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
Creating and using them
|
|
-----------------------
|
|
|
|
In the Scene tree dock, right-click on a node and select
|
|
**Access as Scene Unique Name** in the context menu.
|
|
|
|
.. image:: img/unique_name.png
|
|
|
|
After checking this, 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:
|
|
|
|
.. tabs::
|
|
|
|
.. code-tab:: gdscript GDScript
|
|
|
|
get_node("%RedButton").text = "Hello"
|
|
|
|
.. code-tab:: csharp
|
|
|
|
GetNode<Button>("%RedButton").Text = "Hello";
|