Support reimport appending
* Add API: `EditorFileSystem::reimport_append(path)`, thread safe, what can be used from importers when they generate new files within the import process. * Added a `remap.gen_param` custom value to .import files, which can be used by importers to store data needed to generate this file again or not. This API is added to allow the GLTF2 importer to properly extract png files as textures.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "editor_import_plugin.h"
|
||||
|
||||
#include "core/object/script_language.h"
|
||||
#include "editor/editor_file_system.h"
|
||||
|
||||
EditorImportPlugin::EditorImportPlugin() {
|
||||
}
|
||||
@@ -187,6 +188,20 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa
|
||||
ERR_FAIL_V_MSG(ERR_METHOD_NOT_FOUND, "Unimplemented _import in add-on.");
|
||||
}
|
||||
|
||||
Error EditorImportPlugin::_append_import_external_resource(const String &p_file, const Dictionary &p_custom_options, const String &p_custom_importer) {
|
||||
HashMap<StringName, Variant> options;
|
||||
List<Variant> keys;
|
||||
p_custom_options.get_key_list(&keys);
|
||||
for (const Variant &K : keys) {
|
||||
options.insert(K, p_custom_options[K]);
|
||||
}
|
||||
return append_import_external_resource(p_file, options, p_custom_importer);
|
||||
}
|
||||
|
||||
Error EditorImportPlugin::append_import_external_resource(const String &p_file, const HashMap<StringName, Variant> &p_custom_options, const String &p_custom_importer) {
|
||||
return EditorFileSystem::get_singleton()->reimport_append(p_file, p_custom_options, p_custom_importer);
|
||||
}
|
||||
|
||||
void EditorImportPlugin::_bind_methods() {
|
||||
GDVIRTUAL_BIND(_get_importer_name)
|
||||
GDVIRTUAL_BIND(_get_visible_name)
|
||||
@@ -200,4 +215,5 @@ void EditorImportPlugin::_bind_methods() {
|
||||
GDVIRTUAL_BIND(_get_import_order)
|
||||
GDVIRTUAL_BIND(_get_option_visibility, "path", "option_name", "options")
|
||||
GDVIRTUAL_BIND(_import, "source_file", "save_path", "options", "platform_variants", "gen_files");
|
||||
ClassDB::bind_method(D_METHOD("append_import_external_resource", "path", "custom_options", "custom_importer"), &EditorImportPlugin::_append_import_external_resource, DEFVAL(Dictionary()), DEFVAL(String()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user