diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 071a0287e6..3cf46e5b91 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -845,15 +845,16 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c font->draw(canvas_item, pos, sampled_text); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture - preview_done = false; + VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant()); while (!preview_done) { OS::get_singleton()->delay_usec(10); } + VS::get_singleton()->canvas_item_clear(canvas_item); + Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); @@ -878,7 +879,11 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c Ref<Texture> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 p_size) const { - return generate_from_path(p_from->get_path(), p_size); + String path = p_from->get_path(); + if (!FileAccess::exists(path)) { + return Ref<Texture>(); + } + return generate_from_path(path, p_size); } EditorFontPreviewPlugin::EditorFontPreviewPlugin() { |