diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 0f7af27d072..5b003f53e9b 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -100,6 +100,13 @@ Ref EditorTexturePreviewPlugin::generate(const Ref &p_from, return Ref(); } + if (atlas->is_compressed()) { + atlas = atlas->duplicate(); + if (atlas->decompress() != OK) { + return Ref(); + } + } + if (!tex_atlas->get_region().has_area()) { return Ref(); } diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 561146be425..fcda832c911 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -132,8 +132,21 @@ static Image::Format get_texture_2d_format(const Ref &p_texture) { static int get_texture_mipmaps_count(const Ref &p_texture) { ERR_FAIL_COND_V(p_texture.is_null(), -1); + // We are having to download the image only to get its mipmaps count. It would be nice if we didn't have to. - Ref image = p_texture->get_image(); + Ref image; + Ref at = p_texture; + if (at.is_valid()) { + // The AtlasTexture tries to obtain the region from the atlas as an image, + // which will fail if it is a compressed format. + Ref atlas = at->get_atlas(); + if (atlas.is_valid()) { + image = atlas->get_image(); + } + } else { + image = p_texture->get_image(); + } + if (image.is_valid()) { return image->get_mipmap_count(); }