2
0

class_resourceuid.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/ResourceUID.xml.
  6. .. _class_ResourceUID:
  7. ResourceUID
  8. ===========
  9. **Inherits:** :ref:`Object<class_Object>`
  10. A singleton that manages the unique identifiers of all resources within a project.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Resource UIDs (Unique IDentifiers) allow the engine to keep references between resources intact, even if files are renamed or moved. They can be accessed with ``uid://``.
  15. \ **ResourceUID** keeps track of all registered resource UIDs in a project, generates new UIDs, and converts between their string and integer representations.
  16. .. rst-class:: classref-reftable-group
  17. Methods
  18. -------
  19. .. table::
  20. :widths: auto
  21. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  22. | |void| | :ref:`add_id<class_ResourceUID_method_add_id>`\ (\ id\: :ref:`int<class_int>`, path\: :ref:`String<class_String>`\ ) |
  23. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`create_id<class_ResourceUID_method_create_id>`\ (\ ) |
  25. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`create_id_for_path<class_ResourceUID_method_create_id_for_path>`\ (\ path\: :ref:`String<class_String>`\ ) |
  27. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`String<class_String>` | :ref:`ensure_path<class_ResourceUID_method_ensure_path>`\ (\ path_or_uid\: :ref:`String<class_String>`\ ) |static| |
  29. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`String<class_String>` | :ref:`get_id_path<class_ResourceUID_method_get_id_path>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
  31. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`has_id<class_ResourceUID_method_has_id>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
  33. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`String<class_String>` | :ref:`id_to_text<class_ResourceUID_method_id_to_text>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
  35. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`String<class_String>` | :ref:`path_to_uid<class_ResourceUID_method_path_to_uid>`\ (\ path\: :ref:`String<class_String>`\ ) |static| |
  37. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  38. | |void| | :ref:`remove_id<class_ResourceUID_method_remove_id>`\ (\ id\: :ref:`int<class_int>`\ ) |
  39. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  40. | |void| | :ref:`set_id<class_ResourceUID_method_set_id>`\ (\ id\: :ref:`int<class_int>`, path\: :ref:`String<class_String>`\ ) |
  41. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`text_to_id<class_ResourceUID_method_text_to_id>`\ (\ text_id\: :ref:`String<class_String>`\ ) |const| |
  43. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`String<class_String>` | :ref:`uid_to_path<class_ResourceUID_method_uid_to_path>`\ (\ uid\: :ref:`String<class_String>`\ ) |static| |
  45. +-----------------------------+----------------------------------------------------------------------------------------------------------------------+
  46. .. rst-class:: classref-section-separator
  47. ----
  48. .. rst-class:: classref-descriptions-group
  49. Constants
  50. ---------
  51. .. _class_ResourceUID_constant_INVALID_ID:
  52. .. rst-class:: classref-constant
  53. **INVALID_ID** = ``-1`` :ref:`🔗<class_ResourceUID_constant_INVALID_ID>`
  54. The value to use for an invalid UID, for example if the resource could not be loaded.
  55. Its text representation is ``uid://<invalid>``.
  56. .. rst-class:: classref-section-separator
  57. ----
  58. .. rst-class:: classref-descriptions-group
  59. Method Descriptions
  60. -------------------
  61. .. _class_ResourceUID_method_add_id:
  62. .. rst-class:: classref-method
  63. |void| **add_id**\ (\ id\: :ref:`int<class_int>`, path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_ResourceUID_method_add_id>`
  64. Adds a new UID value which is mapped to the given resource path.
  65. Fails with an error if the UID already exists, so be sure to check :ref:`has_id()<class_ResourceUID_method_has_id>` beforehand, or use :ref:`set_id()<class_ResourceUID_method_set_id>` instead.
  66. .. rst-class:: classref-item-separator
  67. ----
  68. .. _class_ResourceUID_method_create_id:
  69. .. rst-class:: classref-method
  70. :ref:`int<class_int>` **create_id**\ (\ ) :ref:`🔗<class_ResourceUID_method_create_id>`
  71. Generates a random resource UID which is guaranteed to be unique within the list of currently loaded UIDs.
  72. In order for this UID to be registered, you must call :ref:`add_id()<class_ResourceUID_method_add_id>` or :ref:`set_id()<class_ResourceUID_method_set_id>`.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_ResourceUID_method_create_id_for_path:
  76. .. rst-class:: classref-method
  77. :ref:`int<class_int>` **create_id_for_path**\ (\ path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_ResourceUID_method_create_id_for_path>`
  78. Like :ref:`create_id()<class_ResourceUID_method_create_id>`, but the UID is seeded with the provided ``path`` and project name. UIDs generated for that path will be always the same within the current project.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_ResourceUID_method_ensure_path:
  82. .. rst-class:: classref-method
  83. :ref:`String<class_String>` **ensure_path**\ (\ path_or_uid\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_ResourceUID_method_ensure_path>`
  84. Returns a path, converting ``path_or_uid`` if necessary. Prints an error if provided an invalid UID.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_ResourceUID_method_get_id_path:
  88. .. rst-class:: classref-method
  89. :ref:`String<class_String>` **get_id_path**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_ResourceUID_method_get_id_path>`
  90. Returns the path that the given UID value refers to.
  91. Fails with an error if the UID does not exist, so be sure to check :ref:`has_id()<class_ResourceUID_method_has_id>` beforehand.
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_ResourceUID_method_has_id:
  95. .. rst-class:: classref-method
  96. :ref:`bool<class_bool>` **has_id**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_ResourceUID_method_has_id>`
  97. Returns whether the given UID value is known to the cache.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_ResourceUID_method_id_to_text:
  101. .. rst-class:: classref-method
  102. :ref:`String<class_String>` **id_to_text**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_ResourceUID_method_id_to_text>`
  103. Converts the given UID to a ``uid://`` string value.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_ResourceUID_method_path_to_uid:
  107. .. rst-class:: classref-method
  108. :ref:`String<class_String>` **path_to_uid**\ (\ path\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_ResourceUID_method_path_to_uid>`
  109. Converts the provided resource ``path`` to a UID. Returns the unchanged path if it has no associated UID.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_ResourceUID_method_remove_id:
  113. .. rst-class:: classref-method
  114. |void| **remove_id**\ (\ id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ResourceUID_method_remove_id>`
  115. Removes a loaded UID value from the cache.
  116. Fails with an error if the UID does not exist, so be sure to check :ref:`has_id()<class_ResourceUID_method_has_id>` beforehand.
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_ResourceUID_method_set_id:
  120. .. rst-class:: classref-method
  121. |void| **set_id**\ (\ id\: :ref:`int<class_int>`, path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_ResourceUID_method_set_id>`
  122. Updates the resource path of an existing UID.
  123. Fails with an error if the UID does not exist, so be sure to check :ref:`has_id()<class_ResourceUID_method_has_id>` beforehand, or use :ref:`add_id()<class_ResourceUID_method_add_id>` instead.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_ResourceUID_method_text_to_id:
  127. .. rst-class:: classref-method
  128. :ref:`int<class_int>` **text_to_id**\ (\ text_id\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_ResourceUID_method_text_to_id>`
  129. Extracts the UID value from the given ``uid://`` string.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_ResourceUID_method_uid_to_path:
  133. .. rst-class:: classref-method
  134. :ref:`String<class_String>` **uid_to_path**\ (\ uid\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_ResourceUID_method_uid_to_path>`
  135. Converts the provided ``uid`` to a path. Prints an error if the UID is invalid.
  136. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  137. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  138. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  139. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  140. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  141. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  142. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  143. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  144. .. |void| replace:: :abbr:`void (No return value.)`