mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
242 lines
11 KiB
ReStructuredText
242 lines
11 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. _class_ResourceUID:
|
||
|
||
ResourceUID
|
||
===========
|
||
|
||
**Hérite de :** :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 are 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
|
||
|
||
Méthodes
|
||
----------------
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`add_id<class_ResourceUID_method_add_id>`\ (\ id\: :ref:`int<class_int>`, path\: :ref:`String<class_String>`\ ) |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`create_id<class_ResourceUID_method_create_id>`\ (\ ) |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`create_id_for_path<class_ResourceUID_method_create_id_for_path>`\ (\ path\: :ref:`String<class_String>`\ ) |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`ensure_path<class_ResourceUID_method_ensure_path>`\ (\ path_or_uid\: :ref:`String<class_String>`\ ) |static| |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`get_id_path<class_ResourceUID_method_get_id_path>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`has_id<class_ResourceUID_method_has_id>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`id_to_text<class_ResourceUID_method_id_to_text>`\ (\ id\: :ref:`int<class_int>`\ ) |const| |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`path_to_uid<class_ResourceUID_method_path_to_uid>`\ (\ path\: :ref:`String<class_String>`\ ) |static| |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`remove_id<class_ResourceUID_method_remove_id>`\ (\ id\: :ref:`int<class_int>`\ ) |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| |void| | :ref:`set_id<class_ResourceUID_method_set_id>`\ (\ id\: :ref:`int<class_int>`, path\: :ref:`String<class_String>`\ ) |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`text_to_id<class_ResourceUID_method_text_to_id>`\ (\ text_id\: :ref:`String<class_String>`\ ) |const| |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`uid_to_path<class_ResourceUID_method_uid_to_path>`\ (\ uid\: :ref:`String<class_String>`\ ) |static| |
|
||
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
Constantes
|
||
--------------------
|
||
|
||
.. _class_ResourceUID_constant_INVALID_ID:
|
||
|
||
.. rst-class:: classref-constant
|
||
|
||
**INVALID_ID** = ``-1`` :ref:`🔗<class_ResourceUID_constant_INVALID_ID>`
|
||
|
||
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
|
||
|
||
Descriptions des méthodes
|
||
--------------------------------------------------
|
||
|
||
.. _class_ResourceUID_method_add_id:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **add_id**\ (\ id\: :ref:`int<class_int>`, path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_ResourceUID_method_add_id>`
|
||
|
||
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**\ (\ ) :ref:`🔗<class_ResourceUID_method_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_create_id_for_path:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **create_id_for_path**\ (\ path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_ResourceUID_method_create_id_for_path>`
|
||
|
||
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.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_ResourceUID_method_ensure_path:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **ensure_path**\ (\ path_or_uid\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_ResourceUID_method_ensure_path>`
|
||
|
||
Returns a path, converting ``path_or_uid`` if necessary. Fails and returns an empty string if an invalid UID is provided.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_ResourceUID_method_get_id_path:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **get_id_path**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_ResourceUID_method_get_id_path>`
|
||
|
||
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**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_ResourceUID_method_has_id>`
|
||
|
||
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**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_ResourceUID_method_id_to_text>`
|
||
|
||
Converts the given UID to a ``uid://`` string value.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_ResourceUID_method_path_to_uid:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **path_to_uid**\ (\ path\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_ResourceUID_method_path_to_uid>`
|
||
|
||
Converts the provided resource ``path`` to a UID. Returns the unchanged path if it has no associated UID.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_ResourceUID_method_remove_id:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
|void| **remove_id**\ (\ id\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ResourceUID_method_remove_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**\ (\ id\: :ref:`int<class_int>`, path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_ResourceUID_method_set_id>`
|
||
|
||
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**\ (\ text_id\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_ResourceUID_method_text_to_id>`
|
||
|
||
Extracts the UID value from the given ``uid://`` string.
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_ResourceUID_method_uid_to_path:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **uid_to_path**\ (\ uid\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_ResourceUID_method_uid_to_path>`
|
||
|
||
Converts the provided ``uid`` to a path. Prints an error if the UID is invalid.
|
||
|
||
.. |virtual| replace:: :abbr:`virtual (Cette méthode doit typiquement être redéfinie par l'utilisateur pour avoir un effet.)`
|
||
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
||
.. |const| replace:: :abbr:`const (Cette méthode n'a pas d'effets de bord. Elle ne modifie aucune des variables membres de l'instance.)`
|
||
.. |vararg| replace:: :abbr:`vararg (Cette méthode accepte n'importe quel nombre d'arguments après ceux décris ici.)`
|
||
.. |constructor| replace:: :abbr:`constructor (Cette méthode est utilisée pour construire un type.)`
|
||
.. |static| replace:: :abbr:`static (Cette méthode n'a pas besoin d'instance pour être appelée, elle peut donc être directement appelée en utilisant le nom de la classe.)`
|
||
.. |operator| replace:: :abbr:`operator (Cette méthode décrit un opérateur valide à utiliser avec ce type en tant qu'opérande gauche.)`
|
||
.. |bitfield| replace:: :abbr:`BitField (Cette valeur est un nombre entier composé d'un masque de bits des options suivantes.)`
|
||
.. |void| replace:: :abbr:`void (Aucune valeur de retour.)`
|