Replies: 1 comment 1 reply
-
I would like to know if there is a solution for that too. For now, my workaround is using generic: pub struct MyPlugin<T>
where
T: States,
{
pub states: Vec<T>,
}
impl<T> MyPlugin<T>
where
T: States,
{
pub fn new(states: Vec<T>) -> Self {
Self { states }
}
pub fn any() -> Self {
Self { states: Vec::new() }
}
}
impl<T> Plugin for MyPlugin<T>
where
T: States,
{
fn build(&self, app: &mut App) {
if self.states.is_empty() {
app.add_systems(Update, my_system);
} else {
for state in &self.states {
app.add_systems(Update, my_system.run_if(in_state(state.clone())));
}
}
}
} Sometimes, I just provide the system, and let the game add that system by itself. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have cammera movement plugin that I would like to keep universal (not bound to a specific state names), but run it only when in specific game state.
Is there a way in Bevy to tie a plugin with a state?
I would expect the StartUp systems to identify with OnEnter and Update system to has an extra .run_if(in_state(...))
Beta Was this translation helpful? Give feedback.
All reactions