ResourceUid
Asset identifiers and UID-to-path registry.
A UID identifies an asset, contains no asset data and is not a game Entity ID. Numeric value, uid:// text and path are different representations. Candidate creation, file-header changes and path registration are separate operations.
CreateId()/CreateIdForPath() do not register results. HasId() checks a map, not a file. PathToUid() can return the original path; current SetId() can leave an old reverse entry even after RemoveId(), a reproduced defect.
Use normal editor tools for ordinary asset operations; manage an owned runtime map explicitly and never dispose the engine-owned Singleton. ResourceSaver.SetUid does not replace registration. Tests were Windows headless; editor scanning, cross-process cache and other platforms remain untested.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties1
SingletonProperty
public static ResourceUidInstance Singleton { get; }Borrowed wrapper of the global engine service. Repeated access uses a cached managed wrapper, not a separate registry. Do not Free()/Dispose() this engine-owned object. Use the class static methods for ordinary work.
Methods12
AddIdvoid
public static void AddId(long id, string path);Adds an ID→path process-registry entry and, with reverse cache enabled, path→ID. Creates no file, changes no file UID header and renames no asset. An existing ID is rejected with a diagnostic. Supply an owned valid ID and exact path; map mutation does not certify persisted cache updates.
| Name | Type | Default |
|---|---|---|
id | long | — |
path | string | — |
idNonnegative ID; account for registry membership/ownership for map operations.
pathExact asset path; the method does not create or move the file.
CreateIdlong
public static long CreateId();Generates a nonnegative 63-bit candidate absent from the current registry. Does not reserve it, call AddId or create a file. Generator failure can return InvalidId. Obtaining an ID proves no asset existence; perform AddId separately for an owned registration.
longNonnegative unregistered candidate or InvalidId.
CreateIdForPathlong
public static long CreateIdForPath(string path);Creates a candidate seeded by project name, lowercased path and content MD5, skipping registered IDs. Registers nothing and creates no file. Repetition without registration gave the same ID; content/project/registry changes need not. A nonexistent path can also yield a valid candidate, so this is neither an existence test nor stable content addressing.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathExact asset path; the method does not create or move the file.
longUnregistered candidate; not proof of an existing file.
EnsurePathstring
public static string EnsurePath(string pathOrUid);Uses UidToPath() for strings starting with uid://; otherwise returns input unchanged even if no file exists. Creates no directory, checks no permissions and is not complete input validation. Unknown UIDs inherit UidToPath() diagnostics/empty result.
| Name | Type | Default |
|---|---|---|
pathOrUid | string | — |
pathOrUidOrdinary path or uid://; an ordinary path is returned without existence validation.
stringResolved UID path or unchanged ordinary path; existence is not guaranteed.
GetIdPathstring
public static string GetIdPath(long id);Gets the registered ID path without opening or validating the file. In runtime validate a nonnegative ID and HasId() first. InvalidId/unknown IDs can produce diagnostics and empty string. Editor fallback/scanning differs and was not executed here.
| Name | Type | Default |
|---|---|---|
id | long | — |
idNonnegative ID; account for registry membership/ownership for map operations.
stringRegistered path or empty on absence/error.
HasIdbool
public static bool HasId(long id);Checks a key in the current registry, not a disk file or reverse-map freshness. Can be false after RemoveId() while an old reverse path from SetId remains; tested. Does not scan the project or load a resource.
| Name | Type | Default |
|---|---|---|
id | long | — |
idNonnegative ID; account for registry membership/ownership for map operations.
boolTrue for a current registry key; not a file/reverse-map check.
IdToTextstring
public static string IdToText(long id);Encodes a nonnegative ID as uid:// text without checking registration or file existence. Any negative value yields uid://<invalid>. ID encoding, not registration creation or asset-content serialization.
| Name | Type | Default |
|---|---|---|
id | long | — |
idNonnegative ID; account for registry membership/ownership for map operations.
stringuid:// text or uid://<invalid> for negative values.
PathToUidstring
public static string PathToUid(string path);Queries the path UID through ResourceLoader. Runtime uses reverse cache; unknown UID returns the original path, not InvalidId or necessarily empty string. A stale reverse path after SetId/RemoveId can return UID text with HasId() already false. Check result form/current registration; creates no file or UID.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathExact asset path; the method does not create or move the file.
stringUID text or original path; distinguish them explicitly.
RemoveIdvoid
public static void RemoveId(long id);Removes the ID and its current reverse-path entry, not the file or embedded UID. If SetId previously left an old reverse path, RemoveId does not clear it; reproduced defect. Missing IDs produce diagnostics. Automatic persistence/rebuilding of the whole cache is not established by this operation.
| Name | Type | Default |
|---|---|---|
id | long | — |
idNonnegative ID; account for registry membership/ownership for map operations.
SetIdvoid
public static void SetId(long id, string path);Updates the path of an existing registered ID without moving the file. 1.0.0 limitation: adds the new reverse path but does not erase the old one, so PathToUid(oldPath) can still return that UID; reproduced. To avoid this in an owned runtime update, remove the old registration before adding the new path under the same ID instead of SetId; not atomic. Missing IDs produce diagnostics.
| Name | Type | Default |
|---|---|---|
id | long | — |
path | string | — |
idNonnegative ID; account for registry membership/ownership for map operations.
pathExact asset path; the method does not create or move the file.
TextToIdlong
public static long TextToId(string textId);Parses uid:// as a nonnegative ID or InvalidId for rejected input. Not strict canonical UID validation: empty uid:// suffix gives 0, and overflow has no separate diagnostic. Checks no registry/file. For strict input compare canonical IdToText() and separately HasId().
| Name | Type | Default |
|---|---|---|
textId | string | — |
textIduid:// text; canonical form and ID presence are separate checks.
longNumeric ID or -1; a numeric result does not establish registration.
UidToPathstring
public static string UidToPath(string uid);Parses UID text and queries its registered path. Does not automatically find a moved file. Unknown/invalid IDs can produce diagnostics and empty string; check TextToId()/HasId() before runtime calls. A returned path proves no file existence.
| Name | Type | Default |
|---|---|---|
uid | string | — |
uidRegistered UID text, not an ordinary file path.
stringRegistry path or empty result; not a filesystem check.
Fields and constants1
InvalidIdField
public const long InvalidId = -1;The -1 constant for absent/invalid ID. Not a usable UID or an AddId/GetIdPath key. IdToText() maps negative values to uid://<invalid>, not a file path.