Skip to content

Commit

Permalink
fix: fix debug mode
Browse files Browse the repository at this point in the history
* make GalaxyDebugPlugin work onto on debug_assertions cfg flag
fix a doc comment
* cargo-bundle asset path set only when conditions are correct for it
  • Loading branch information
Sycrosity committed Sep 1, 2023
1 parent b306129 commit a269a5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
use bevy::input::common_conditions::input_toggle_active;
use bevy::{input::common_conditions::input_toggle_active, window::close_on_esc};
use bevy_inspector_egui::quick::{StateInspectorPlugin, WorldInspectorPlugin};

use crate::prelude::*;

/// Backslash = KeyCode::Backslash
///
/// Adds helpful features for debugging, like a [WorldInspectorPlugin] and
/// [StateInspectorPlugin]. These can (by default) be toggled by pressing the
/// Backslash (`\`) keycode.
pub struct GalaxyDebugPlugin;

impl Plugin for GalaxyDebugPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(
WorldInspectorPlugin::default().run_if(input_toggle_active(true, KeyCode::Backslash)),
)
.add_plugin(
StateInspectorPlugin::<EngineState>::default()
.run_if(input_toggle_active(true, KeyCode::Backslash)),
);
if cfg!(debug_assertions) {
app.add_plugin(
WorldInspectorPlugin::default()
.run_if(input_toggle_active(true, KeyCode::Backslash)),
)
.add_plugin(
StateInspectorPlugin::<EngineState>::default()
.run_if(input_toggle_active(true, KeyCode::Backslash)),
);
app.add_system(close_on_esc);
}
}
}
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ fn main() {
.set(AssetPlugin {
watch_for_changes: true,
asset_folder: {
if cfg!(target_os = "macos") {
if cfg!(all(
target_os = "macos",
not(debug_assertions),
not(features = "dynamic_linking")
)) {
"../Resources/assets".to_string()
} else {
"assets".to_string()
Expand Down

0 comments on commit a269a5c

Please sign in to comment.