From 32b43cfeb38dc83ba8024acec32bdfc706c86a46 Mon Sep 17 00:00:00 2001 From: reduz Date: Fri, 23 Jul 2021 16:01:18 -0300 Subject: Implement Resource UIDs * Most resource types now have unique identifiers. * Applies to text, binary and imported resources. * File formats reference both by text and UID (when available). UID always has priority. * Resource UIDs are 64 bits for better compatibility with the engine. * Can be represented and used textually, example `uuid://dapwmgsmnl28u`. * A special binary cache file is used and exported, containing the mappings. Example of how it looks: ```GDScript [gd_scene load_steps=2 format=3 uid="uid://dw86wq31afig2"] [ext_resource type="PackedScene" uid="uid://bt36ojelx8q6c" path="res://subscene.scn" id="1_t56hs"] ``` GDScript, shaders and other special resource files can't currently provide UIDs, but this should be doable with special keywords on the files. This will be reserved for future PRs. --- core/object/class_db.cpp | 4 ++++ core/object/class_db.h | 1 + 2 files changed, 5 insertions(+) (limited to 'core/object') diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index e2db5918e3..f871dd464a 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -1496,6 +1496,10 @@ void ClassDB::get_resource_base_extensions(List *p_extensions) { } } +bool ClassDB::is_resource_extension(const StringName &p_extension) { + return resource_base_extensions.has(p_extension); +} + void ClassDB::get_extensions_for_type(const StringName &p_class, List *p_extensions) { const StringName *K = nullptr; diff --git a/core/object/class_db.h b/core/object/class_db.h index fd574fd2d8..3a84e9ab38 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -396,6 +396,7 @@ public: static void add_resource_base_extension(const StringName &p_extension, const StringName &p_class); static void get_resource_base_extensions(List *p_extensions); static void get_extensions_for_type(const StringName &p_class, List *p_extensions); + static bool is_resource_extension(const StringName &p_extension); static void add_compatibility_class(const StringName &p_class, const StringName &p_fallback); -- cgit v1.2.3