From 390bb23675a3e7c05881a8e55705b8848d0da086 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 13 Feb 2023 23:03:38 +0100 Subject: [PATCH] Improve Image preview in the inspector --- editor/plugins/texture_editor_plugin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 2fb624b7130..283e906052e 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -152,11 +152,15 @@ TexturePreview::TexturePreview(Ref p_texture, bool p_show_metadata) { } bool EditorInspectorPluginTexture::can_handle(Object *p_object) { - return Object::cast_to(p_object) != nullptr || Object::cast_to(p_object) != nullptr || Object::cast_to(p_object) != nullptr || Object::cast_to(p_object) != nullptr; + return Object::cast_to(p_object) != nullptr || Object::cast_to(p_object) != nullptr || Object::cast_to(p_object) != nullptr || Object::cast_to(p_object) != nullptr || Object::cast_to(p_object) != nullptr; } void EditorInspectorPluginTexture::parse_begin(Object *p_object) { Ref texture(Object::cast_to(p_object)); + if (texture.is_null()) { + Ref image(Object::cast_to(p_object)); + texture = ImageTexture::create_from_image(image); + } add_custom_control(memnew(TexturePreview(texture, true))); }