diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index a2c36b1f3ce6..9a53f07a3fc8 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -112,9 +112,13 @@ Ref EditorTexturePreviewPlugin::generate(const Ref &p_from, return Ref(); } - const int mid_depth = (tex_3d->get_depth() - 1) / 2; - Vector> data = tex_3d->get_data(); + if (data.size() != tex_3d->get_depth()) { + return Ref(); + } + + // Use the middle slice for the thumbnail. + const int mid_depth = (tex_3d->get_depth() - 1) / 2; if (!data.is_empty() && data[mid_depth].is_valid()) { img = data[mid_depth]->duplicate(); } @@ -124,6 +128,7 @@ Ref EditorTexturePreviewPlugin::generate(const Ref &p_from, return Ref(); } + // Use the middle slice for the thumbnail. const int mid_layer = (tex_lyr->get_layers() - 1) / 2; Ref data = tex_lyr->get_layer_data(mid_layer);