Up to date

This page is up to date for Godot 4.2. 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

add_id ( int id, String path )

int

create_id ( )

String

get_id_path ( int id ) const

bool

has_id ( int id ) const

String

id_to_text ( int id ) const

void

remove_id ( int id )

void

set_id ( int id, String path )

int

text_to_id ( String text_id ) 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 ( int id, String path )

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 ord