|
I've simplified my code down to the bare minimum to describe the problem. The goal is to remove a lot of boilerplate I have. I'm not sure what needs to be done in order for use bevy::{
prelude::*,
ecs::system::SystemParam,
};
pub trait Trait {
type Assoc: SystemParam + Send + Sync + 'static;
fn system(query: Self::Assoc) {
}
}
#[derive(Default)]
pub struct MyPlugin<T: Trait + Send + Sync>(std::marker::PhantomData<T>);
impl<T: Trait + Send + Sync + 'static> Plugin for MyPlugin<T> {
fn build(&self, app: &mut App) {
app.add_systems(Update, T::system);
}
}
fn main() {} |
Answered by
hymm
Feb 12, 2024
Replies: 1 comment 1 reply
|
You should use SystemParamItem for the system parameters type instead of SystemParam. I have a branch with an improved example here https://github.com/hymm/bevy/blob/3ab4f50cbf3082057df10b1d72accd55e83ae8e3/examples/ecs/generic_system.rs#L146 |
1 reply
Answer selected by
bilowik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should use SystemParamItem for the system parameters type instead of SystemParam. I have a branch with an improved example here https://github.com/hymm/bevy/blob/3ab4f50cbf3082057df10b1d72accd55e83ae8e3/examples/ecs/generic_system.rs#L146