diff --git a/crates/bevy_gltf_components/Cargo.toml b/crates/bevy_gltf_components/Cargo.toml index 2e50ece..56092bf 100644 --- a/crates/bevy_gltf_components/Cargo.toml +++ b/crates/bevy_gltf_components/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_gltf_components" -version = "0.2.1" +version = "0.2.2" authors = ["Mark 'kaosat-dev' Moissette"] description = "Allows you to define [Bevy](https://bevyengine.org/) components direclty inside gltf files and instanciate the components on the Bevy side." homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" diff --git a/crates/bevy_gltf_components/README.md b/crates/bevy_gltf_components/README.md index 9b63d1e..554ec64 100644 --- a/crates/bevy_gltf_components/README.md +++ b/crates/bevy_gltf_components/README.md @@ -60,7 +60,7 @@ bevy_gltf_components = { version = "0.2"} Add the following to your `[dependencies]` section in `Cargo.toml`: ```toml -bevy_gltf_components = "0.1" +bevy_gltf_components = "0.2" ``` Or use `cargo add`: diff --git a/crates/bevy_gltf_components/src/process_gltfs.rs b/crates/bevy_gltf_components/src/process_gltfs.rs index 1353a47..f83266c 100644 --- a/crates/bevy_gltf_components/src/process_gltfs.rs +++ b/crates/bevy_gltf_components/src/process_gltfs.rs @@ -1,3 +1,5 @@ +use std::path::Path; +use bevy::asset::AssetPath; use bevy::gltf::Gltf; use bevy::utils::HashSet; use bevy::{asset::LoadState, prelude::*}; @@ -30,11 +32,18 @@ pub fn track_new_gltf( ) { for event in events.read() { if let AssetEvent::Added { id } = event { - let handle = asset_server - .get_id_handle(*id) - .expect("this gltf should have been loaded"); - tracker.add_gltf(handle.clone()); - debug!("gltf created {:?}", handle.clone()); + + let handle = asset_server.get_id_handle(*id); + if let Some(handle) = handle { + tracker.add_gltf(handle.clone()); + debug!("gltf created {:?}", handle); + } else { + let asset_path = asset_server.get_path(*id).unwrap_or(AssetPath::from_path(Path::new("n/a".into()))); // will unfortunatly not work, will do a PR/ discussion at the Bevy level, leaving for reference, would be very practical + warn!( + "a gltf file ({:?}) has no handle available, cannot inject components", + asset_path + ) + } } } events.clear();