diff options
| author | hondres | 2016-01-19 04:27:27 +0100 |
|---|---|---|
| committer | hondres | 2016-01-19 04:27:27 +0100 |
| commit | 4cca09921d7515b5896c4a60615399a879616b73 (patch) | |
| tree | 8a0cbcbdbaec5c81898a69c6b72c148b58c35b4e /tools/editor/plugins/editor_preview_plugins.cpp | |
| parent | d1bb868a193d33896df12d289341391ef6d4e8f3 (diff) | |
| download | godot-4cca09921d7515b5896c4a60615399a879616b73.tar.gz godot-4cca09921d7515b5896c4a60615399a879616b73.tar.zst godot-4cca09921d7515b5896c4a60615399a879616b73.zip | |
thumbnail preview for AtlasTextures
Diffstat (limited to 'tools/editor/plugins/editor_preview_plugins.cpp')
| -rw-r--r-- | tools/editor/plugins/editor_preview_plugins.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index a0ce29421..f3b527257 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<Texture> EditorTexturePreviewPlugin::generate(const RES& p_from) { - Ref<ImageTexture> tex =p_from; - Image img = tex->get_data(); + Image img; + Ref<AtlasTexture> atex = p_from; + if (atex.is_valid()) { + Ref<ImageTexture> tex = atex->get_atlas(); + if (!tex.is_valid()) { + return Ref<Texture>(); + } + Image atlas = tex->get_data(); + img = atlas.get_rect(atex->get_region()); + } + else { + Ref<ImageTexture> tex = p_from; + img = tex->get_data(); + } + if (img.empty()) return Ref<Texture>(); |
