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
- func AddId(id Resource.UID, path string)
- func Advanced() class
- func CreateId() int
- func CreateIdForPath(path string) int
- func EnsurePath(path_or_uid string) string
- func GetIdPath(id Resource.UID) string
- func HasId(id Resource.UID) bool
- func IdToText(id Resource.UID) string
- func PathToUid(path string) string
- func RemoveId(id Resource.UID)
- func SetId(id Resource.UID, path string)
- func TextToId(text_id string) int
- func UidToPath(uid string) string
- type Extension
- type ID
- type Instance
Constants ¶
const InvalidId Resource.UID = -1 //gd:ResourceUID.INVALID_ID
Variables ¶
This section is empty.
Functions ¶
func AddId ¶
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 ¶
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 ¶
Returns a path, converting 'path_or_uid' if necessary. Prints an error if provided an invalid UID.
func GetIdPath ¶
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 PathToUid ¶
Converts the provided resource 'path' to a UID. Returns the unchanged path if it has no associated UID.
func RemoveId ¶
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 ¶
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.
Types ¶
type Extension ¶
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
type 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.
type Instance ¶
type Instance [1]gdclass.ResourceUID
Instance of the class with convieniently typed arguments and results.