diff --git a/editor/editor_interface.cpp b/editor/editor_interface.cpp index 51645cee54a..13c123b999c 100644 --- a/editor/editor_interface.cpp +++ b/editor/editor_interface.cpp @@ -230,9 +230,12 @@ Vector> EditorInterface::make_mesh_previews(const Vectoris_editor_hint() || !DisplayServer::get_singleton()->window_can_draw()) { + return; + } + ERR_FAIL_COND_MSG(p_path.is_empty(), "Path is empty, cannot generate preview."); + ERR_FAIL_NULL_MSG(p_scene, "The provided scene is null, cannot generate preview."); ERR_FAIL_COND_MSG(p_scene->is_inside_tree(), "The scene must not be inside the tree."); - ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be called from the editor."); ERR_FAIL_NULL_MSG(EditorNode::get_singleton(), "EditorNode doesn't exist."); SubViewport *sub_viewport_node = memnew(SubViewport); diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index 64e870ca17c..b11e5e66eae 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -2963,15 +2963,6 @@ 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 &p_options) { Ref importer; String ext = p_source_file.get_extension().to_lower(); @@ -3359,7 +3350,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); + EditorInterface::get_singleton()->make_scene_preview(p_source_file, scene, 1024); } else { ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Unknown scene import type: " + _scene_import_type); } diff --git a/editor/import/3d/resource_importer_scene.h b/editor/import/3d/resource_importer_scene.h index 071d294b0e3..27c68758a19 100644 --- a/editor/import/3d/resource_importer_scene.h +++ b/editor/import/3d/resource_importer_scene.h @@ -232,7 +232,6 @@ class ResourceImporterScene : public ResourceImporter { }; void _optimize_track_usage(AnimationPlayer *p_player, AnimationImportTracks *p_track_actions); - void _generate_editor_preview_for_scene(const String &p_path, Node *p_scene); String _scene_import_type = "PackedScene";