class_nodepath.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the NodePath.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_NodePath:
  5. NodePath
  6. ========
  7. **Category:** Built-In Types
  8. Brief Description
  9. -----------------
  10. Pre-parsed scene tree path.
  11. Member Functions
  12. ----------------
  13. +----------------------------------+----------------------------------------------------------------------------------------+
  14. | :ref:`NodePath<class_nodepath>` | :ref:`NodePath<class_NodePath_NodePath>` **(** :ref:`String<class_string>` from **)** |
  15. +----------------------------------+----------------------------------------------------------------------------------------+
  16. | :ref:`NodePath<class_nodepath>` | :ref:`get_as_property_path<class_NodePath_get_as_property_path>` **(** **)** |
  17. +----------------------------------+----------------------------------------------------------------------------------------+
  18. | :ref:`String<class_string>` | :ref:`get_concatenated_subnames<class_NodePath_get_concatenated_subnames>` **(** **)** |
  19. +----------------------------------+----------------------------------------------------------------------------------------+
  20. | :ref:`String<class_string>` | :ref:`get_name<class_NodePath_get_name>` **(** :ref:`int<class_int>` idx **)** |
  21. +----------------------------------+----------------------------------------------------------------------------------------+
  22. | :ref:`int<class_int>` | :ref:`get_name_count<class_NodePath_get_name_count>` **(** **)** |
  23. +----------------------------------+----------------------------------------------------------------------------------------+
  24. | :ref:`String<class_string>` | :ref:`get_subname<class_NodePath_get_subname>` **(** :ref:`int<class_int>` idx **)** |
  25. +----------------------------------+----------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`get_subname_count<class_NodePath_get_subname_count>` **(** **)** |
  27. +----------------------------------+----------------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`is_absolute<class_NodePath_is_absolute>` **(** **)** |
  29. +----------------------------------+----------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`is_empty<class_NodePath_is_empty>` **(** **)** |
  31. +----------------------------------+----------------------------------------------------------------------------------------+
  32. Description
  33. -----------
  34. 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.
  35. 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 ``NodePath`` or the literal syntax ``@"path"``. Exporting a ``NodePath`` variable will give you a node selection widget in the properties panel of the editor, which can often be useful.
  36. A ``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.
  37. Member Function Description
  38. ---------------------------
  39. .. _class_NodePath_NodePath:
  40. - :ref:`NodePath<class_nodepath>` **NodePath** **(** :ref:`String<class_string>` from **)**
  41. 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.
  42. .. _class_NodePath_get_as_property_path:
  43. - :ref:`NodePath<class_nodepath>` **get_as_property_path** **(** **)**
  44. .. _class_NodePath_get_concatenated_subnames:
  45. - :ref:`String<class_string>` **get_concatenated_subnames** **(** **)**
  46. .. _class_NodePath_get_name:
  47. - :ref:`String<class_string>` **get_name** **(** :ref:`int<class_int>` idx **)**
  48. Get the node name indicated by ``idx`` (0 to :ref:`get_name_count<class_NodePath_get_name_count>`)
  49. .. _class_NodePath_get_name_count:
  50. - :ref:`int<class_int>` **get_name_count** **(** **)**
  51. Get the number of node names which make up the path.
  52. .. _class_NodePath_get_subname:
  53. - :ref:`String<class_string>` **get_subname** **(** :ref:`int<class_int>` idx **)**
  54. Get the resource name indicated by ``idx`` (0 to :ref:`get_subname_count<class_NodePath_get_subname_count>`)
  55. .. _class_NodePath_get_subname_count:
  56. - :ref:`int<class_int>` **get_subname_count** **(** **)**
  57. Get the number of resource names in the path.
  58. .. _class_NodePath_is_absolute:
  59. - :ref:`bool<class_bool>` **is_absolute** **(** **)**
  60. Return true if the node path is absolute (not relative).
  61. .. _class_NodePath_is_empty:
  62. - :ref:`bool<class_bool>` **is_empty** **(** **)**
  63. Return true if the node path is empty.