RichoDemus/bevy-console

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

Closed this issue · 1 comments

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

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.