mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Prevent generating editor 3D scene preview in headless mode.
This commit is contained in:
parent
2a9ff39264
commit
706601778e
3 changed files with 6 additions and 13 deletions
|
@ -230,9 +230,12 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh
|
|||
}
|
||||
|
||||
void EditorInterface::make_scene_preview(const String &p_path, Node *p_scene, int p_preview_size) {
|
||||
ERR_FAIL_NULL_MSG(p_scene, "The provided scene is null.");
|
||||
if (!Engine::get_singleton()->is_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);
|
||||
|
|
|
@ -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<StringName, Variant> &p_options) {
|
||||
Ref<EditorSceneFormatImporter> 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);
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue