diff options
Diffstat (limited to 'editor/import/3d/resource_importer_scene.cpp')
-rw-r--r-- | editor/import/3d/resource_importer_scene.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index 554d6bc748..3477b696aa 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -36,6 +36,7 @@ #include "core/io/dir_access.h" #include "core/io/resource_saver.h" #include "core/object/script_language.h" +#include "editor/editor_interface.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor/import/3d/scene_import_settings.h" @@ -2314,6 +2315,7 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor } } + // TODO: If there are more than 2 or equal get_internal_option_visibility method, visibility state is broken. for (int i = 0; i < post_importer_plugins.size(); i++) { Variant ret = post_importer_plugins.write[i]->get_internal_option_visibility(EditorScenePostImportPlugin::InternalImportCategory(p_category), _scene_import_type, p_option, p_options); if (ret.get_type() == Variant::BOOL) { @@ -2816,6 +2818,15 @@ void ResourceImporterScene::_optimize_track_usage(AnimationPlayer *p_player, Ani } } +void ResourceImporterScene::_generate_editor_preview_for_scene(const String &p_path, Node *p_scene) { + if (!Engine::get_singleton()->is_editor_hint()) { + return; + } + ERR_FAIL_COND_MSG(p_path.is_empty(), "Path is empty, cannot generate preview."); + ERR_FAIL_NULL_MSG(p_scene, "Scene is null, cannot generate preview."); + EditorInterface::get_singleton()->make_scene_preview(p_path, p_scene, 1024); +} + Node *ResourceImporterScene::pre_import(const String &p_source_file, const HashMap<StringName, Variant> &p_options) { Ref<EditorSceneFormatImporter> importer; String ext = p_source_file.get_extension().to_lower(); @@ -3166,6 +3177,7 @@ Error ResourceImporterScene::import(ResourceUID::ID p_source_id, const String &p print_verbose("Saving scene to: " + p_save_path + ".scn"); err = ResourceSaver::save(packer, p_save_path + ".scn", flags); //do not take over, let the changed files reload themselves ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save scene to file '" + p_save_path + ".scn'."); + _generate_editor_preview_for_scene(p_source_file, scene); } else { ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unknown scene import type: " + _scene_import_type); } |