From 9c37ca5383a13bdd06ab2ff4f90f4a117199fbc2 Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 22 May 2025 15:08:22 +0200 Subject: [PATCH] Expose helper methods for converting UIDs --- core/io/resource_uid.cpp | 4 ++++ doc/classes/ResourceUID.xml | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp index 7dbf52d4c9c5..bc25a1828989 100644 --- a/core/io/resource_uid.cpp +++ b/core/io/resource_uid.cpp @@ -364,6 +364,10 @@ void ResourceUID::_bind_methods() { ClassDB::bind_method(D_METHOD("get_id_path", "id"), &ResourceUID::get_id_path); ClassDB::bind_method(D_METHOD("remove_id", "id"), &ResourceUID::remove_id); + ClassDB::bind_static_method("ResourceUID", D_METHOD("uid_to_path", "uid"), &ResourceUID::uid_to_path); + ClassDB::bind_static_method("ResourceUID", D_METHOD("path_to_uid", "path"), &ResourceUID::path_to_uid); + ClassDB::bind_static_method("ResourceUID", D_METHOD("ensure_path", "path_or_uid"), &ResourceUID::ensure_path); + BIND_CONSTANT(INVALID_ID) } ResourceUID *ResourceUID::singleton = nullptr; diff --git a/doc/classes/ResourceUID.xml b/doc/classes/ResourceUID.xml index a87fb32898a1..250034225ffb 100644 --- a/doc/classes/ResourceUID.xml +++ b/doc/classes/ResourceUID.xml @@ -33,6 +33,13 @@ 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. + + + + + Returns a path, converting [param path_or_uid] if necessary. Prints an error if provided an invalid UID. + + @@ -55,6 +62,13 @@ Converts the given UID to a [code]uid://[/code] string value. + + + + + Converts the provided resource [param path] to a UID. Returns the unchanged path if it has no associated UID. + + @@ -79,6 +93,13 @@ Extracts the UID value from the given [code]uid://[/code] string. + + + + + Converts the provided [param uid] to a path. Prints an error if the UID is invalid. + +