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/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. Singleton for managing a cache of resource UIDs within a project.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Resources can not only be referenced using their resource paths ``res://``, but alternatively through a unique identifier specified via ``uid://``.
  15. Using UIDs allows for the engine to keep references between resources intact, even if the files get renamed or moved.
  16. This singleton is responsible for keeping track of all registered resource UIDs of a project, generating new UIDs and converting between the string and integer representation.
  17. .. rst-class:: classref-reftable-group
  18. Methods
  19. -------
  20. .. table::
  21. :widths: auto
  22. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`add_id<class_ResourceUID_method_add_id>` **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)** |
  24. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`create_id<class_ResourceUID_method_create_id>` **(** **)** |
  26. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`String<class_String>` | :ref:`get_id_path<class_ResourceUID_method_get_id_path>` **(** :ref:`int<class_int>` id **)** |const| |
  28. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`has_id<class_ResourceUID_method_has_id>` **(** :ref:`int<class_int>` id **)** |const| |
  30. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`String<class_String>` | :ref:`id_to_text<class_ResourceUID_method_id_to_text>` **(** :ref:`int<class_int>` id **)** |const| |
  32. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`remove_id<class_ResourceUID_method_remove_id>` **(** :ref:`int<class_int>` id **)** |
  34. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set_id<class_ResourceUID_method_set_id>` **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)** |
  36. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`text_to_id<class_ResourceUID_method_text_to_id>` **(** :ref:`String<class_String>` text_id **)** |const| |
  38. +-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
  39. .. rst-class:: classref-section-separator
  40. ----
  41. .. rst-class:: classref-descriptions-group
  42. Constants
  43. ---------
  44. .. _class_ResourceUID_constant_INVALID_ID:
  45. .. rst-class:: classref-constant
  46. **INVALID_ID** = ``-1``
  47. The value to use for an invalid UID, for example if the resource could not be loaded.
  48. Its text representation is ``uid://<invalid>``.
  49. .. rst-class:: classref-section-separator
  50. ----
  51. .. rst-class:: classref-descriptions-group
  52. Method Descriptions
  53. -------------------
  54. .. _class_ResourceUID_method_add_id:
  55. .. rst-class:: classref-method
  56. void **add_id** **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)**
  57. Adds a new UID value which is mapped to the given resource path.
  58. 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.
  59. .. rst-class:: classref-item-separator
  60. ----
  61. .. _class_ResourceUID_method_create_id:
  62. .. rst-class:: classref-method
  63. :ref:`int<class_int>` **create_id** **(** **)**
  64. Generates a random resource UID which is guaranteed to be unique within the list of currently loaded UIDs.
  65. 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>`.
  66. .. rst-class:: classref-item-separator
  67. ----
  68. .. _class_ResourceUID_method_get_id_path:
  69. .. rst-class:: classref-method
  70. :ref:`String<class_String>` **get_id_path** **(** :ref:`int<class_int>` id **)** |const|
  71. Returns the path that the given UID value refers to.
  72. Fails with an error if the UID does not exist, so be sure to check :ref:`has_id<class_ResourceUID_method_has_id>` beforehand.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_ResourceUID_method_has_id:
  76. .. rst-class:: classref-method
  77. :ref:`bool<class_bool>` **has_id** **(** :ref:`int<class_int>` id **)** |const|
  78. Returns whether the given UID value is known to the cache.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_ResourceUID_method_id_to_text:
  82. .. rst-class:: classref-method
  83. :ref:`String<class_String>` **id_to_text** **(** :ref:`int<class_int>` id **)** |const|
  84. Converts the given UID to a ``uid://`` string value.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_ResourceUID_method_remove_id:
  88. .. rst-class:: classref-method
  89. void **remove_id** **(** :ref:`int<class_int>` id **)**
  90. Removes a loaded UID value from the cache.
  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_set_id:
  95. .. rst-class:: classref-method
  96. void **set_id** **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)**
  97. Updates the resource path of an existing UID.
  98. 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.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_ResourceUID_method_text_to_id:
  102. .. rst-class:: classref-method
  103. :ref:`int<class_int>` **text_to_id** **(** :ref:`String<class_String>` text_id **)** |const|
  104. Extracts the UID value from the given ``uid://`` string.
  105. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  106. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  107. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  108. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  109. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  110. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`