Table of Contents

Class ResourceUid

Namespace
Godot
Assembly
GodotSharp.dll

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.

[GodotClassName("ResourceUID")]
public static class ResourceUid
Inheritance
ResourceUid
Inherited Members

Fields

InvalidId

The value to use for an invalid UID, for example if the resource could not be loaded.

Its text representation is uid://<invalid>.

public const long InvalidId = -1

Field Value

long

Properties

Singleton

public static ResourceUidInstance Singleton { get; }

Property Value

ResourceUidInstance

Methods

AddId(long, 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 HasId(long) beforehand, or use SetId(long, string) instead.

public static void AddId(long id, string path)

Parameters

id long
path string

CreateId()

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 AddId(long, string) or SetId(long, string).

public static long CreateId()

Returns

long

GetIdPath(long)

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 HasId(long) beforehand.

public static string GetIdPath(long id)

Parameters

id long

Returns

string

HasId(long)

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

public static bool HasId(long id)

Parameters

id long

Returns

bool

IdToText(long)

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

public static string IdToText(long id)

Parameters

id long

Returns

string

RemoveId(long)

Removes a loaded UID value from the cache.

Fails with an error if the UID does not exist, so be sure to check HasId(long) beforehand.

public static void RemoveId(long id)

Parameters

id long

SetId(long, string)

Updates the resource path of an existing UID.

Fails with an error if the UID does not exist, so be sure to check HasId(long) beforehand, or use AddId(long, string) instead.

public static void SetId(long id, string path)

Parameters

id long
path string

TextToId(string)

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

public static long TextToId(string textId)

Parameters

textId string

Returns

long