Files
godot-docs-l10n/classes/zh_CN/class_resourceuid.rst

190 lines
7.8 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/4.4/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/4.4/doc/classes/ResourceUID.xml.
.. _class_ResourceUID:
ResourceUID
===========
**继承:** :ref:`Object<class_Object>`
管理项目中所有资源的唯一标识符的单例。
.. rst-class:: classref-introduction-group
描述
----
资源 UIDUnique IDentifier唯一标识符可以使引擎保持资源之间引用关系的完整性即使文件发生重命名或移动。可以使用 ``uid://`` 访问。
\ **ResourceUID** 能够跟踪项目中所有已注册的资源 UID生成新的 UID也能够将标识符在字符串表示和整数表示之间进行转换。
.. rst-class:: classref-reftable-group
方法
----
.. 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:`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| |
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
| |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| |
+-----------------------------+----------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
常量
----
.. _class_ResourceUID_constant_INVALID_ID:
.. rst-class:: classref-constant
**INVALID_ID** = ``-1`` :ref:`🔗<class_ResourceUID_constant_INVALID_ID>`
用于无效 UID 的值,例如无法加载的资源。
对应的文本表示为 ``uid://<invalid>``\ 。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
方法说明
--------
.. _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>`
添加一个新的 UID 值,将其映射到给定的资源路径。
如果 UID 已经存在,则会返回错误,因此请务必先使用 :ref:`has_id()<class_ResourceUID_method_has_id>` 进行检查,或者改用 :ref:`set_id()<class_ResourceUID_method_set_id>`\ 。
.. 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>`
生成随机的资源 UID该 UID 在当前加载的 UID 列表中保证唯一。
要注册这个 UID你必须调用 :ref:`add_id()<class_ResourceUID_method_add_id>` 或 :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**\ (\ id\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_ResourceUID_method_get_id_path>`
返回给定 UID 值引用的路径。
如果 UID 不存在则失败并报错,因此请务必使用 :ref:`has_id()<class_ResourceUID_method_has_id>` 事先检查。
.. 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>`
返回给定的 UID 值是否为缓存所知。
.. 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>`
将给定的 UID 转换为 ``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>`
从缓存中删除一个已加载的 UID 值。
如果 UID 不存在则失败并报错,因此请务必提前使用 :ref:`has_id()<class_ResourceUID_method_has_id>` 检查。
.. 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>`
更新现有 UID 的资源路径。
如果 UID 不存在,则失败并出现错误,因此请务必提前使用 :ref:`has_id()<class_ResourceUID_method_has_id>` 检查,或者改用 :ref:`add_id()<class_ResourceUID_method_add_id>`\ 。
.. 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>`
从给定的 ``uid://`` 字符串中提取 UID 值。
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
.. |void| replace:: :abbr:`void (无返回值。)`