RichoDemus / bevy-console

MIT License
285 stars 63 forks source link

Run UI system depending on `run_if` instead of key press #53

Closed aecsocket closed 9 months ago

aecsocket commented 1 year ago

It would be nice to allow the ConsolePlugin to accept a run condition on which to run the UI system, rather than a key press being the only possible way to toggle the console show/hide. I propose a solution like bevy_inspector_egui taking a fn run_if, which allows a user to set the run condition.

An example use case would be:

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, States)]
pub enum DebugState {
    #[default]
    Closed,
    Opened,
}

app
    .add_state::<DebugState>()
    .add_plugins(ConsolePlugin.run_if(in_state(DebugState::Opened)))

And another part of the app would be responsible for changing the current DebugState.

Xion commented 1 year ago

You can already open/close the console programmatically by changing the bool inside the ConsoleOpen resource. Disabling the default keys is the matter of inserting a ConsoleConfiguration resource with empty keys field.