ResourceUID

继承: Object

A singleton that manages the unique identifiers of all resources within a project.

描述

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.

方法

voidadd_id ( id: int, path: String )
intcreate_id ( )
Stringget_id_path ( id: int ) const1
boolhas_id ( id: int ) const1
Stringid_to_text ( id: int ) const1
voidremove_id ( id: int )
voidset_id ( id: int, path: String )
inttext_to_id ( text_id: String ) const1

常量

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>.


方法说明

void add_id ( id: int, path: String )

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 has_id beforehand, or use set_id instead.


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 add_id or set_id.


String get_id_path ( id: int ) const1

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 has_id beforehand.


bool has_id ( id: int ) const1

Returns whether the given UID value is known to the cache.


String id_to_text ( id: int ) const1

Converts the given UID to a uid:// string value.


void remove_id ( id: int )

Removes a loaded UID value from the cache.

Fails with an error if the UID does not exist, so be sure to check has_id beforehand.


void set_id ( id: int, path: String )

Updates the resource path of an existing UID.

Fails with an error if the UID does not exist, so be sure to check has_id beforehand, or use add_id instead.


int text_to_id ( text_id: String ) const1

Extracts the UID value from the given uid:// string.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。