class_nodepath.rst 5.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_NodePath:
  4. NodePath
  5. ========
  6. **Category:** Built-In Types
  7. Brief Description
  8. -----------------
  9. Pre-parsed scene tree path.
  10. Member Functions
  11. ----------------
  12. +----------------------------------+-----------------------------------------------------------------------------------------+
  13. | :ref:`NodePath<class_nodepath>` | :ref:`NodePath<class_NodePath_NodePath>` **(** :ref:`String<class_string>` from **)** |
  14. +----------------------------------+-----------------------------------------------------------------------------------------+
  15. | :ref:`String<class_string>` | :ref:`get_name<class_NodePath_get_name>` **(** :ref:`int<class_int>` idx **)** |
  16. +----------------------------------+-----------------------------------------------------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`get_name_count<class_NodePath_get_name_count>` **(** **)** |
  18. +----------------------------------+-----------------------------------------------------------------------------------------+
  19. | :ref:`String<class_string>` | :ref:`get_property<class_NodePath_get_property>` **(** **)** |
  20. +----------------------------------+-----------------------------------------------------------------------------------------+
  21. | :ref:`String<class_string>` | :ref:`get_subname<class_NodePath_get_subname>` **(** :ref:`int<class_int>` idx **)** |
  22. +----------------------------------+-----------------------------------------------------------------------------------------+
  23. | :ref:`int<class_int>` | :ref:`get_subname_count<class_NodePath_get_subname_count>` **(** **)** |
  24. +----------------------------------+-----------------------------------------------------------------------------------------+
  25. | :ref:`bool<class_bool>` | :ref:`is_absolute<class_NodePath_is_absolute>` **(** **)** |
  26. +----------------------------------+-----------------------------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`is_empty<class_NodePath_is_empty>` **(** **)** |
  28. +----------------------------------+-----------------------------------------------------------------------------------------+
  29. Description
  30. -----------
  31. A pre-parsed relative or absolute path in a scene tree, for use with :ref:`Node.get_node<class_Node_get_node>` and similar functions. It can reference a node, a resource within a node, or a property of a node or resource. For instance, ``"Path2D/PathFollow2D/Sprite:texture:size"`` would refer to the size property of the texture resource on the node named "Sprite" which is a child of the other named nodes in the path. Note that if you want to get a resource, you must end the path with a colon, otherwise the last element will be used as a property name.
  32. You will usually just pass a string to :ref:`Node.get_node<class_Node_get_node>` and it will be automatically converted, but you may occasionally want to parse a path ahead of time with :ref:`NodePath<class_nodepath>` or the literal syntax ``@"path"``. Exporting a :ref:`NodePath<class_nodepath>` variable will give you a node selection widget in the properties panel of the editor, which can often be useful.
  33. A :ref:`NodePath<class_nodepath>` is made up of a list of node names, a list of "subnode" (resource) names, and the name of a property in the final node or resource.
  34. Member Function Description
  35. ---------------------------
  36. .. _class_NodePath_NodePath:
  37. - :ref:`NodePath<class_nodepath>` **NodePath** **(** :ref:`String<class_string>` from **)**
  38. Create a NodePath from a string, e.g. "Path2D/PathFollow2D/Sprite:texture:size". A path is absolute if it starts with a slash. Absolute paths are only valid in the global scene tree, not within individual scenes. In a relative path, ``"."`` and ``".."`` indicate the current node and its parent.
  39. .. _class_NodePath_get_name:
  40. - :ref:`String<class_string>` **get_name** **(** :ref:`int<class_int>` idx **)**
  41. Get the node name indicated by ``idx`` (0 to :ref:`get_name_count<class_NodePath_get_name_count>`)
  42. .. _class_NodePath_get_name_count:
  43. - :ref:`int<class_int>` **get_name_count** **(** **)**
  44. Get the number of node names which make up the path.
  45. .. _class_NodePath_get_property:
  46. - :ref:`String<class_string>` **get_property** **(** **)**
  47. Get the path's property name, or an empty string if the path doesn't have a property.
  48. .. _class_NodePath_get_subname:
  49. - :ref:`String<class_string>` **get_subname** **(** :ref:`int<class_int>` idx **)**
  50. Get the resource name indicated by ``idx`` (0 to :ref:`get_subname_count<class_NodePath_get_subname_count>`)
  51. .. _class_NodePath_get_subname_count:
  52. - :ref:`int<class_int>` **get_subname_count** **(** **)**
  53. Get the number of resource names in the path.
  54. .. _class_NodePath_is_absolute:
  55. - :ref:`bool<class_bool>` **is_absolute** **(** **)**
  56. Return true if the node path is absolute (not relative).
  57. .. _class_NodePath_is_empty:
  58. - :ref:`bool<class_bool>` **is_empty** **(** **)**
  59. Return true if the node path is empty.