mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
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
This commit is contained in:
parent
fe32a60577
commit
7835c92647
1 changed files with 8 additions and 2 deletions
|
@ -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));
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue