ResourceUID

package
v0.0.0-...-e1beaa7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

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

graphics.gd/classdb/ResourceUID keeps track of all registered resource UIDs in a project, generates new UIDs, and converts between their string and integer representations.

Index

Constants

View Source
const InvalidId Resource.UID = -1 //gd:ResourceUID.INVALID_ID

Variables

This section is empty.

Functions

func AddId

func AddId(id Resource.UID, 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 HasId beforehand, or use SetId instead.

func Advanced

func Advanced() class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

func CreateId

func CreateId() int

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

func CreateIdForPath

func CreateIdForPath(path string) int

Like CreateId, but the UID is seeded with the provided 'path' and project name. UIDs generated for that path will be always the same within the current project.

func EnsurePath

func EnsurePath(path_or_uid string) string

Returns a path, converting 'path_or_uid' if necessary. Prints an error if provided an invalid UID.

func GetIdPath

func GetIdPath(id Resource.UID) string

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

func HasId

func HasId(id Resource.UID) bool

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

func IdToText

func IdToText(id Resource.UID) string

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

func PathToUid

func PathToUid(path string) string

Converts the provided resource 'path' to a UID. Returns the unchanged path if it has no associated UID.

func RemoveId

func RemoveId(id Resource.UID)

Removes a loaded UID value from the cache.

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

func SetId

func SetId(id Resource.UID, 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 HasId beforehand, or use AddId instead.

func TextToId

func TextToId(text_id string) int

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

func UidToPath

func UidToPath(uid string) string

Converts the provided 'uid' to a path. Prints an error if the UID is invalid.

Types

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.ResourceUID

Instance of the class with convieniently typed arguments and results.

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) ID

func (self Instance) ID() ID

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL