Up to date
This page is up to date for Godot 4.3
.
If you still find outdated information, please open an issue.
ResourceUIDΒΆ
Inherits: Object
A singleton that manages the unique identifiers of all resources within a project.
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.
MethodsΒΆ
void |
|
get_id_path(id: int) const |
|
id_to_text(id: int) const |
|
void |
|
void |
|
text_to_id(text_id: String) const |
ConstantsΒΆ
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>
.
Method DescriptionsΒΆ
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.
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) 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 has_id beforehand.
bool has_id(id: int) const π
Returns whether the given UID value is known to the cache.
String id_to_text(id: int) const π
Converts the given UID to a uid://
string value.
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) const π
Extracts the UID value from the given uid://
string.