mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
188 lines
7.4 KiB
ReStructuredText
188 lines
7.4 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. DO NOT EDIT THIS FILE!!!
|
|
.. Generated automatically from Godot engine sources.
|
|
.. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
|
|
.. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/ResourceUID.xml.
|
|
|
|
.. _class_ResourceUID:
|
|
|
|
ResourceUID
|
|
===========
|
|
|
|
**Inherits:** :ref:`Object<class_Object>`
|
|
|
|
A singleton that manages the unique identifiers of all resources within a project.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Description
|
|
-----------
|
|
|
|
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://``.
|
|
|
|
\ **ResourceUID** keeps track of all registered resource UIDs in a project, generates new UIDs, and converts between their string and integer representations.
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Methods
|
|
-------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`add_id<class_ResourceUID_method_add_id>` **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)** |
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`create_id<class_ResourceUID_method_create_id>` **(** **)** |
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_id_path<class_ResourceUID_method_get_id_path>` **(** :ref:`int<class_int>` id **)** |const| |
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`has_id<class_ResourceUID_method_has_id>` **(** :ref:`int<class_int>` id **)** |const| |
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`id_to_text<class_ResourceUID_method_id_to_text>` **(** :ref:`int<class_int>` id **)** |const| |
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`remove_id<class_ResourceUID_method_remove_id>` **(** :ref:`int<class_int>` id **)** |
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_id<class_ResourceUID_method_set_id>` **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)** |
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`text_to_id<class_ResourceUID_method_text_to_id>` **(** :ref:`String<class_String>` text_id **)** |const| |
|
|
+-----------------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Constants
|
|
---------
|
|
|
|
.. _class_ResourceUID_constant_INVALID_ID:
|
|
|
|
.. rst-class:: classref-constant
|
|
|
|
**INVALID_ID** = ``-1``
|
|
|
|
The value to use for an invalid UID, for example if the resource could not be loaded.
|
|
|
|
Its text representation is ``uid://<invalid>``.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_ResourceUID_method_add_id:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **add_id** **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)**
|
|
|
|
Adds a new UID value which is mapped to the given resource path.
|
|
|
|
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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_ResourceUID_method_create_id:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **create_id** **(** **)**
|
|
|
|
Generates a random resource UID which is guaranteed to be unique within the list of currently loaded UIDs.
|
|
|
|
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>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_ResourceUID_method_get_id_path:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **get_id_path** **(** :ref:`int<class_int>` id **)** |const|
|
|
|
|
Returns the path that the given UID value refers to.
|
|
|
|
Fails with an error if the UID does not exist, so be sure to check :ref:`has_id<class_ResourceUID_method_has_id>` beforehand.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_ResourceUID_method_has_id:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **has_id** **(** :ref:`int<class_int>` id **)** |const|
|
|
|
|
Returns whether the given UID value is known to the cache.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_ResourceUID_method_id_to_text:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`String<class_String>` **id_to_text** **(** :ref:`int<class_int>` id **)** |const|
|
|
|
|
Converts the given UID to a ``uid://`` string value.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_ResourceUID_method_remove_id:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **remove_id** **(** :ref:`int<class_int>` id **)**
|
|
|
|
Removes a loaded UID value from the cache.
|
|
|
|
Fails with an error if the UID does not exist, so be sure to check :ref:`has_id<class_ResourceUID_method_has_id>` beforehand.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_ResourceUID_method_set_id:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **set_id** **(** :ref:`int<class_int>` id, :ref:`String<class_String>` path **)**
|
|
|
|
Updates the resource path of an existing UID.
|
|
|
|
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.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_ResourceUID_method_text_to_id:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **text_to_id** **(** :ref:`String<class_String>` text_id **)** |const|
|
|
|
|
Extracts the UID value from the given ``uid://`` string.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
|
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
|
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
|
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|