| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="ResourceUID" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | A singleton that manages the unique identifiers of all resources within a project. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | 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 [code]uid://[/code]. |
| 8 | [ResourceUID] keeps track of all registered resource UIDs in a project, generates new UIDs, and converts between their string and integer representations. |
| 9 | </description> |
| 10 | <tutorials> |
| 11 | </tutorials> |
| 12 | <methods> |
| 13 | <method name="add_id"> |
| 14 | <return type="void" /> |
| 15 | <param index="0" name="id" type="int" /> |
| 16 | <param index="1" name="path" type="String" /> |
| 17 | <description> |
| 18 | Adds a new UID value which is mapped to the given resource path. |
| 19 | Fails with an error if the UID already exists, so be sure to check [method has_id] beforehand, or use [method set_id] instead. |
| 20 | </description> |
| 21 | </method> |
| 22 | <method name="create_id"> |
| 23 | <return type="int" /> |
| 24 | <description> |
| 25 | Generates a random resource UID which is guaranteed to be unique within the list of currently loaded UIDs. |
| 26 | In order for this UID to be registered, you must call [method add_id] or [method set_id]. |
| 27 | </description> |
| 28 | </method> |
| 29 | <method name="create_id_for_path"> |
| 30 | <return type="int" /> |
| 31 | <param index="0" name="path" type="String" /> |
| 32 | <description> |
| 33 | Like [method create_id], but the UID is seeded with the provided [param path] and project name. UIDs generated for that path will be always the same within the current project. |
| 34 | </description> |
| 35 | </method> |
| 36 | <method name="ensure_path" qualifiers="static"> |
| 37 | <return type="String" /> |
| 38 | <param index="0" name="path_or_uid" type="String" /> |
| 39 | <description> |
| 40 | Returns a path, converting [param path_or_uid] if necessary. Fails and returns an empty string if an invalid UID is provided. |
| 41 | </description> |
| 42 | </method> |
| 43 | <method name="get_id_path" qualifiers="const"> |
| 44 | <return type="String" /> |
| 45 | <param index="0" name="id" type="int" /> |
| 46 | <description> |
| 47 | Returns the path that the given UID value refers to. |
| 48 | Fails with an error if the UID does not exist, so be sure to check [method has_id] beforehand. |
| 49 | </description> |
| 50 | </method> |
| 51 | <method name="has_id" qualifiers="const"> |
| 52 | <return type="bool" /> |
| 53 | <param index="0" name="id" type="int" /> |
| 54 | <description> |
| 55 | Returns whether the given UID value is known to the cache. |
| 56 | </description> |
| 57 | </method> |
| 58 | <method name="id_to_text" qualifiers="const"> |
| 59 | <return type="String" /> |
| 60 | <param index="0" name="id" type="int" /> |
| 61 | <description> |
| 62 | Converts the given UID to a [code]uid://[/code] string value. |
| 63 | </description> |
| 64 | </method> |
| 65 | <method name="path_to_uid" qualifiers="static"> |
| 66 | <return type="String" /> |
| 67 | <param index="0" name="path" type="String" /> |
| 68 | <description> |
| 69 | Converts the provided resource [param path] to a UID. Returns the unchanged path if it has no associated UID. |
| 70 | </description> |
| 71 | </method> |
| 72 | <method name="remove_id"> |
| 73 | <return type="void" /> |
| 74 | <param index="0" name="id" type="int" /> |
| 75 | <description> |
| 76 | Removes a loaded UID value from the cache. |
| 77 | Fails with an error if the UID does not exist, so be sure to check [method has_id] beforehand. |
| 78 | </description> |
| 79 | </method> |
| 80 | <method name="set_id"> |
| 81 | <return type="void" /> |
| 82 | <param index="0" name="id" type="int" /> |
| 83 | <param index="1" name="path" type="String" /> |
| 84 | <description> |
| 85 | Updates the resource path of an existing UID. |
| 86 | Fails with an error if the UID does not exist, so be sure to check [method has_id] beforehand, or use [method add_id] instead. |
| 87 | </description> |
| 88 | </method> |
| 89 | <method name="text_to_id" qualifiers="const"> |
| 90 | <return type="int" /> |
| 91 | <param index="0" name="text_id" type="String" /> |
| 92 | <description> |
| 93 | Extracts the UID value from the given [code]uid://[/code] string. |
| 94 | </description> |
| 95 | </method> |
| 96 | <method name="uid_to_path" qualifiers="static"> |
| 97 | <return type="String" /> |
| 98 | <param index="0" name="uid" type="String" /> |
| 99 | <description> |
| 100 | Converts the provided [param uid] to a path. Prints an error if the UID is invalid. |
| 101 | </description> |
| 102 | </method> |
| 103 | </methods> |
| 104 | <constants> |
| 105 | <constant name="INVALID_ID" value="-1"> |
| 106 | The value to use for an invalid UID, for example if the resource could not be loaded. |
| 107 | Its text representation is [code]uid://<invalid>[/code]. |
| 108 | </constant> |
| 109 | </constants> |
| 110 | </class> |