summaryrefslogtreecommitdiffstats
path: root/editor/import/3d/resource_importer_scene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/import/3d/resource_importer_scene.cpp')
-rw-r--r--editor/import/3d/resource_importer_scene.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp
index 86af9caf26..6c45d89125 100644
--- a/editor/import/3d/resource_importer_scene.cpp
+++ b/editor/import/3d/resource_importer_scene.cpp
@@ -34,6 +34,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"
@@ -2814,6 +2815,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();
@@ -3164,6 +3174,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);
}