From 7835c926478f623893ab8818e937e80767b72df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Tue, 8 Jun 2021 02:46:44 +0000 Subject: [PATCH] Log errors when loading textures from a gltf file (#2260) When loading a gltf, if there is an error loading textures, it is completely ignored. This can happen for example when loading a file with `jpg` textures without the `jpeg` Bevy feature enabled. This PR adds `warn` logs for the few cases that can happen when loading a texture. Other possible fix would be to break on first error and returning, making the asset loading failed --- crates/bevy_gltf/src/loader.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 6c80c0b999643..efc41b6378333 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -4,6 +4,7 @@ use bevy_asset::{ }; use bevy_core::Name; use bevy_ecs::world::World; +use bevy_log::warn; use bevy_math::Mat4; use bevy_pbr::prelude::{PbrBundle, StandardMaterial}; use bevy_render::{ @@ -49,7 +50,7 @@ pub enum GltfError { BufferFormatUnsupported, #[error("invalid image mime type: {0}")] InvalidImageMimeType(String), - #[error("{0}")] + #[error("You may need to add the feature for the file format: {0}")] ImageError(#[from] TextureError), #[error("failed to load an asset path: {0}")] AssetIoError(#[from] AssetIoError), @@ -262,7 +263,12 @@ async fn load_gltf<'a, 'b>( }); }) .into_iter() - .filter_map(|result| result.ok()) + .filter_map(|res| { + if let Err(err) = res.as_ref() { + warn!("Error loading GLTF texture: {}", err); + } + res.ok() + }) .for_each(|(texture, label)| { load_context.set_labeled_asset(&label, LoadedAsset::new(texture)); });