Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add criterium for enabling/disabling plugin #4362

Closed
pjankiewicz opened this issue Mar 29, 2022 · 2 comments
Closed

Add criterium for enabling/disabling plugin #4362

pjankiewicz opened this issue Mar 29, 2022 · 2 comments
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled

Comments

@pjankiewicz
Copy link

What problem does this solve or what need does it fill?

Adding criteria for plugins. I use a plugin for camera movement which I wanted to disable on egui widgets. The plugin consists of 2 systems.

app.add_system(camera_movement).add_system(camera_zoom);

What solution would you like?

I would like to use the plugin with ability to restrict it.

fn disable_on_egui_widget(mut egui_ctx: ResMut<EguiContext>) -> ShouldRun {
    if egui_ctx.ctx_mut().wants_pointer_input() || egui_ctx.ctx_mut().wants_keyboard_input() || egui_ctx.ctx_mut().is_pointer_over_area() {
        ShouldRun::No
    } else {
        ShouldRun::Yes
    }
}

app
    .add_plugin_with_criterium(PanCamPlugin, disable_on_egui_widget)

where criterium is some other system.

What alternative(s) have you considered?

The solution I found is I had to copy plugin code to my project and add these conditions in

fn camera_zoom(
    mut egui_ctx: ResMut<EguiContext>,
    mut query: Query<(&PanCam, &mut OrthographicProjection)>,
    mut scroll_events: EventReader<MouseWheel>,
) {
    // added condition to the system
    if egui_ctx.ctx_mut().wants_pointer_input() || egui_ctx.ctx_mut().wants_keyboard_input() || egui_ctx.ctx_mut().is_pointer_over_area() {
        return;
    }
}

Which is not ideal because I don't want to copy plugins into my project only to restrict when they run.

@pjankiewicz pjankiewicz added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Mar 29, 2022
@alice-i-cecile
Copy link
Member

Very much agree with this being a problem.

However, I'm going to close this as a duplicate of #2160 to keep the discussion centralized :)

@pjankiewicz
Copy link
Author

@alice-i-cecile No problem. I will track the issue you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

2 participants