diff --git a/src/debug.rs b/src/debug.rs index 012cfdd..7b66439 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -1,7 +1,5 @@ use bevy::{ - color::palettes::css::{GREY, MAGENTA}, - pbr::wireframe::{WireframeConfig, WireframePlugin}, - platform::collections::HashMap, + color::palettes::css::{GREY, MAGENTA}, gizmos::{aabb::AabbGizmoPlugin, light::LightGizmoPlugin}, pbr::wireframe::{WireframeConfig, WireframePlugin}, platform::collections::HashMap }; use super::*; @@ -14,6 +12,9 @@ impl Plugin for DebuggingPlugin { app.init_state::() .init_resource::() .add_plugins(RapierDebugRenderPlugin::default().disabled()) + // Added by Rapier + // .add_plugins(AabbGizmoPlugin) + // .add_plugins(LightGizmoPlugin) .add_systems(Startup, init_debug_ui) .add_systems( Update, @@ -21,6 +22,10 @@ impl Plugin for DebuggingPlugin { (toggle_state_visibility::,) .run_if(state_changed::), toggle_debug_state.run_if(on_keyboard_press(KeyCode::F12)), + ( + toggle_light_gizmo, + toggle_aabb_gizmo, + ).run_if(state_changed::), ( (hover_mesh, hover_ui) .run_if(on_event::>.or(on_event::>)), @@ -241,3 +246,21 @@ fn enable_wireframe(mut wireframe_config: ResMut) { fn disable_wireframe(mut wireframe_config: ResMut) { wireframe_config.global = false; } + +// Toggle the light gizmo config group +fn toggle_light_gizmo( + state: Res>, + mut config_store: ResMut, +) { + let (_, light_group) = config_store.config_mut::(); + light_group.draw_all = *state.get() == DebuggingState::On; +} + +// Toggle the aabb gizmo config group +fn toggle_aabb_gizmo( + state: Res>, + mut config_store: ResMut, +) { + let (_, aabb_group) = config_store.config_mut::(); + aabb_group.draw_all = *state.get() == DebuggingState::On; +}