mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Generate editor thumbnails on imported scenes.
This commit is contained in:
committed by
K. S. Ernest (iFire) Lee
parent
f952bfe998
commit
74611a74d1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -236,6 +236,7 @@ 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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user