diff --git a/crates/bevy_gltf_component_refs/src/lib.rs b/crates/bevy_gltf_component_refs/src/lib.rs index b953612..fb4cdf1 100644 --- a/crates/bevy_gltf_component_refs/src/lib.rs +++ b/crates/bevy_gltf_component_refs/src/lib.rs @@ -91,13 +91,16 @@ impl GltfRefMap { #[derive(Component, Reflect)] #[reflect(Component)] -struct GltfRef { +struct GltfRef { target: String, #[reflect(ignore)] _marker: PhantomData, } -impl GltfRef { +impl GltfRef +where + Entity: Into, +{ fn system( refs: Query<(Entity, &Self)>, gltf_for_entity: GltfForEntity, @@ -113,7 +116,7 @@ impl GltfRef { match ref_map.get_ref(gltf_root, &gltf_ref.target) { Some(target) => { - commands.entity(entity).insert(T::from_ref(target)); + commands.entity(entity).insert(Into::::into(target)); } None => { warn!( @@ -126,17 +129,14 @@ impl GltfRef { } } -/// Trait for creating a component for a Gltf reference. -pub trait FromGltfRef { - /// Creates `Self` given the `entity` for this reference. - fn from_ref(entity: Entity) -> Self; -} - /// Plugin for automatically converting [`GltfRef`]s into their corresponding /// `T`. -pub struct GltfRefPlugin(PhantomData); +pub struct GltfRefPlugin(PhantomData); -impl Plugin for GltfRefPlugin { +impl Plugin for GltfRefPlugin +where + Entity: Into, +{ fn build(&self, app: &mut App) { app.register_type::>().add_systems( Update, @@ -147,7 +147,10 @@ impl Plugin for GltfRefPlugin { // Manual implementation of Default for GltfRefPlugin to avoid `Default` trait // bounds on `T`. -impl Default for GltfRefPlugin { +impl Default for GltfRefPlugin +where + Entity: Into, +{ fn default() -> Self { Self(Default::default()) }