mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
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.
This commit is contained in:
@@ -47,6 +47,8 @@ class ResourceLoaderBinary {
|
||||
|
||||
uint64_t importmd_ofs = 0;
|
||||
|
||||
ResourceUID::ID uid = ResourceUID::INVALID_ID;
|
||||
|
||||
Vector<char> str_buf;
|
||||
List<RES> resource_cache;
|
||||
|
||||
@@ -57,10 +59,12 @@ class ResourceLoaderBinary {
|
||||
struct ExtResource {
|
||||
String path;
|
||||
String type;
|
||||
ResourceUID::ID uid = ResourceUID::INVALID_ID;
|
||||
RES cache;
|
||||
};
|
||||
|
||||
bool using_named_scene_ids = false;
|
||||
bool using_uids = false;
|
||||
bool use_sub_threads = false;
|
||||
float *progress = nullptr;
|
||||
Vector<ExtResource> external_resources;
|
||||
@@ -94,7 +98,7 @@ public:
|
||||
void set_translation_remapped(bool p_remapped);
|
||||
|
||||
void set_remaps(const Map<String, String> &p_remaps) { remaps = p_remaps; }
|
||||
void open(FileAccess *p_f);
|
||||
void open(FileAccess *p_f, bool p_no_resources = false, bool p_keep_uuid_paths = false);
|
||||
String recognize(FileAccess *p_f);
|
||||
void get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types);
|
||||
|
||||
@@ -109,6 +113,7 @@ public:
|
||||
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
||||
virtual bool handles_type(const String &p_type) const;
|
||||
virtual String get_resource_type(const String &p_path) const;
|
||||
virtual ResourceUID::ID get_resource_uid(const String &p_path) const;
|
||||
virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false);
|
||||
virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map);
|
||||
};
|
||||
@@ -157,7 +162,8 @@ class ResourceFormatSaverBinaryInstance {
|
||||
|
||||
public:
|
||||
enum {
|
||||
FORMAT_FLAG_NAMED_SCENE_IDS = 1
|
||||
FORMAT_FLAG_NAMED_SCENE_IDS = 1,
|
||||
FORMAT_FLAG_UIDS = 2,
|
||||
};
|
||||
Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
|
||||
static void write_variant(FileAccess *f, const Variant &p_property, Map<RES, int> &resource_map, Map<RES, int> &external_resources, Map<StringName, int> &string_map, const PropertyInfo &p_hint = PropertyInfo());
|
||||
|
||||
Reference in New Issue
Block a user