Class ResourceUID
A singleton that manages the unique identifiers of all resources within a project.
- Inheritance
-
ResourceUID
Remarks
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.
Fields
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>
.
const INVALID_ID = -1
Methods
add_id(int, 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 ResourceUID.has_id beforehand, or use ResourceUID.set_id instead.
void add_id(int id, String path)
Parameters
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 ResourceUID.add_id or ResourceUID.set_id.
int create_id
get_id_path(int)
Qualifiers: 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 ResourceUID.has_id beforehand.
String get_id_path(int id)
Parameters
id
int
has_id(int)
Qualifiers: const
Returns whether the given UID value is known to the cache.
bool has_id(int id)
Parameters
id
int
id_to_text(int)
Qualifiers: const
Converts the given UID to a uid://
string value.
String id_to_text(int id)
Parameters
id
int
remove_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 ResourceUID.has_id beforehand.
void remove_id(int id)
Parameters
id
int
set_id(int, String)
Updates the resource path of an existing UID.
Fails with an error if the UID does not exist, so be sure to check ResourceUID.has_id beforehand, or use ResourceUID.add_id instead.
void set_id(int id, String path)
Parameters
text_to_id(String)
Qualifiers: const
Extracts the UID value from the given uid://
string.
int text_to_id(String text_id)
Parameters
text_id
String