From 4cca09921d7515b5896c4a60615399a879616b73 Mon Sep 17 00:00:00 2001 From: hondres Date: Tue, 19 Jan 2016 04:27:27 +0100 Subject: thumbnail preview for AtlasTextures --- tools/editor/plugins/editor_preview_plugins.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tools/editor/plugins') diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index a0ce294219..f3b5272571 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -10,13 +10,26 @@ bool EditorTexturePreviewPlugin::handles(const String& p_type) const { - return ObjectTypeDB::is_type(p_type,"ImageTexture"); + return (ObjectTypeDB::is_type(p_type,"ImageTexture") || ObjectTypeDB::is_type(p_type, "AtlasTexture")); } Ref EditorTexturePreviewPlugin::generate(const RES& p_from) { - Ref tex =p_from; - Image img = tex->get_data(); + Image img; + Ref atex = p_from; + if (atex.is_valid()) { + Ref tex = atex->get_atlas(); + if (!tex.is_valid()) { + return Ref(); + } + Image atlas = tex->get_data(); + img = atlas.get_rect(atex->get_region()); + } + else { + Ref tex = p_from; + img = tex->get_data(); + } + if (img.empty()) return Ref(); -- cgit v1.2.3