class_resourceuid.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/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 can 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>` **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)** |
  23. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`create_id<class_ResourceUID_method_create_id>` **(** **)** |
  25. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`String<class_String>` | :ref:`get_id_path<class_ResourceUID_method_get_id_path>` **(** :ref:`int<class_int>` id **)** |const| |
  27. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`has_id<class_ResourceUID_method_has_id>` **(** :ref:`int<class_int>` id **)** |const| |
  29. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`String<class_String>` | :ref:`id_to_text<class_ResourceUID_method_id_to_text>` **(** :ref:`int<class_int>` id **)** |const| |
  31. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`remove_id<class_ResourceUID_method_remove_id>` **(** :ref:`int<class_int>` id **)** |
  33. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_id<class_ResourceUID_method_set_id>` **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)** |
  35. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`text_to_id<class_ResourceUID_method_text_to_id>` **(** :ref:`String<class_String>` text_id **)** |const| |
  37. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  38. .. rst-class:: classref-section-separator
  39. ----
  40. .. rst-class:: classref-descriptions-group
  41. Constants
  42. ---------
  43. .. _class_ResourceUID_constant_INVALID_ID:
  44. .. rst-class:: classref-constant
  45. **INVALID_ID** = ``-1``
  46. The value to use for an invalid UID, for example if the resource could not be loaded.
  47. Its text representation is ``uid://<invalid>``.
  48. .. rst-class:: classref-section-separator
  49. ----
  50. .. rst-class:: classref-descriptions-group
  51. Method Descriptions
  52. -------------------
  53. .. _class_ResourceUID_method_add_id:
  54. .. rst-class:: classref-method
  55. void **add_id** **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)**
  56. Adds a new UID value which is mapped to the given resource path.
  57. 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.
  58. .. rst-class:: classref-item-separator
  59. ----
  60. .. _class_ResourceUID_method_create_id:
  61. .. rst-class:: classref-method
  62. :ref:`int<class_int>` **create_id** **(** **)**
  63. Generates a random resource UID which is guaranteed to be unique within the list of currently loaded UIDs.
  64. 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>`.
  65. .. rst-class:: classref-item-separator
  66. ----
  67. .. _class_ResourceUID_method_get_id_path:
  68. .. rst-class:: classref-method
  69. :ref:`String<class_String>` **get_id_path** **(** :ref:`int<class_int>` id **)** |const|
  70. Returns the path that the given UID value refers to.
  71. Fails with an error if the UID does not exist, so be sure to check :ref:`has_id<class_ResourceUID_method_has_id>` beforehand.
  72. .. rst-class:: classref-item-separator
  73. ----
  74. .. _class_ResourceUID_method_has_id:
  75. .. rst-class:: classref-method
  76. :ref:`bool<class_bool>` **has_id** **(** :ref:`int<class_int>` id **)** |const|
  77. Returns whether the given UID value is known to the cache.
  78. .. rst-class:: classref-item-separator
  79. ----
  80. .. _class_ResourceUID_method_id_to_text:
  81. .. rst-class:: classref-method
  82. :ref:`String<class_String>` **id_to_text** **(** :ref:`int<class_int>` id **)** |const|
  83. Converts the given UID to a ``uid://`` string value.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_ResourceUID_method_remove_id:
  87. .. rst-class:: classref-method
  88. void **remove_id** **(** :ref:`int<class_int>` id **)**
  89. Removes a loaded UID value from the cache.
  90. Fails with an error if the UID does not exist, so be sure to check :ref:`has_id<class_ResourceUID_method_has_id>` beforehand.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_ResourceUID_method_set_id:
  94. .. rst-class:: classref-method
  95. void **set_id** **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)**
  96. Updates the resource path of an existing UID.
  97. 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.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_ResourceUID_method_text_to_id:
  101. .. rst-class:: classref-method
  102. :ref:`int<class_int>` **text_to_id** **(** :ref:`String<class_String>` text_id **)** |const|
  103. Extracts the UID value from the given ``uid://`` string.
  104. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  105. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  106. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  107. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  108. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  109. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  110. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`