-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #211. Toggle key is backtick, aka `KeyCode::Backquote`. ![2024-08-09_1723243137_1280x720](https://github.com/user-attachments/assets/957af21e-0c18-4ad8-95b7-c7d07aca1bcb)
- Loading branch information
1 parent
ea68850
commit 9cfb8d3
Showing
2 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,30 @@ | ||
//! Development tools for the game. This plugin is only enabled in dev builds. | ||
use bevy::{dev_tools::states::log_transitions, prelude::*}; | ||
use bevy::{ | ||
dev_tools::{ | ||
states::log_transitions, | ||
ui_debug_overlay::{DebugUiPlugin, UiDebugOptions}, | ||
}, | ||
input::common_conditions::input_just_pressed, | ||
prelude::*, | ||
}; | ||
|
||
use crate::screens::Screen; | ||
|
||
pub(super) fn plugin(app: &mut App) { | ||
// Print state transitions in dev builds | ||
// Log `Screen` state transitions. | ||
app.add_systems(Update, log_transitions::<Screen>); | ||
|
||
// Toggle the debug overlay for UI. | ||
app.add_plugins(DebugUiPlugin); | ||
app.add_systems( | ||
Update, | ||
toggle_debug_ui.run_if(input_just_pressed(TOGGLE_KEY)), | ||
); | ||
} | ||
|
||
const TOGGLE_KEY: KeyCode = KeyCode::Backquote; | ||
|
||
fn toggle_debug_ui(mut options: ResMut<UiDebugOptions>) { | ||
options.toggle(); | ||
} |