|
|
|
|
@ -11,6 +11,7 @@ impl Plugin for DebuggingPlugin {
|
|
|
|
|
.init_resource::<ToolTip>()
|
|
|
|
|
.init_resource::<Fps>()
|
|
|
|
|
.init_resource::<EntityCount>()
|
|
|
|
|
.init_resource::<Notice>()
|
|
|
|
|
.add_plugins(RapierDebugRenderPlugin::default().disabled())
|
|
|
|
|
// Added by Rapier
|
|
|
|
|
// .add_plugins(AabbGizmoPlugin)
|
|
|
|
|
@ -32,6 +33,7 @@ impl Plugin for DebuggingPlugin {
|
|
|
|
|
sync_resource_to_ui::<Fps>.run_if(resource_changed::<Fps>),
|
|
|
|
|
track_entity_count,
|
|
|
|
|
sync_resource_to_ui::<EntityCount>.run_if(resource_changed::<EntityCount>),
|
|
|
|
|
sync_resource_to_ui::<Notice>.run_if(resource_changed::<Notice>),
|
|
|
|
|
)
|
|
|
|
|
.run_if(in_state(DebuggingState::On)),
|
|
|
|
|
),
|
|
|
|
|
@ -74,13 +76,29 @@ fn init_debug_ui(mut commands: Commands) {
|
|
|
|
|
children![Text::new(VERSION),],
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
Node {
|
|
|
|
|
width: Val::Auto,
|
|
|
|
|
max_width: Val::Percent(50.0),
|
|
|
|
|
align_self: AlignSelf::End,
|
|
|
|
|
justify_self: JustifySelf::End,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
commands.spawn((
|
|
|
|
|
DebuggingState::On,
|
|
|
|
|
Name::new("Notice"),
|
|
|
|
|
children![(
|
|
|
|
|
Text::new(""),
|
|
|
|
|
SyncResource::<Notice>::default(),
|
|
|
|
|
)],
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
Node {
|
|
|
|
|
max_width: Val::Percent(50.0),
|
|
|
|
|
align_self: AlignSelf::End,
|
|
|
|
|
justify_self: JustifySelf::Start,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
// "Turn on Debugging" button
|
|
|
|
|
commands
|
|
|
|
|
.spawn((
|
|
|
|
|
@ -186,6 +204,15 @@ fn toggle_rapier_debug_render(
|
|
|
|
|
context.enabled = *state.get() == DebuggingState::On;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default, Resource)]
|
|
|
|
|
pub struct Notice(pub String);
|
|
|
|
|
|
|
|
|
|
impl Display for Notice {
|
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
|
writeln!(f, "{}", self.0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Add a generic Tooltip that follows the mouse in debug mode
|
|
|
|
|
#[derive(Default, Resource)]
|
|
|
|
|
pub struct ToolTip(HashMap<String, String>);
|
|
|
|
|
|