|
|
|
@ -67,19 +67,6 @@ pub enum DebuggingState {
|
|
|
|
|
|
|
|
|
|
|
|
/// Create the Debugging UI
|
|
|
|
/// Create the Debugging UI
|
|
|
|
fn init_debug_ui(mut commands: Commands) {
|
|
|
|
fn init_debug_ui(mut commands: Commands) {
|
|
|
|
// "Debugging On" Indicator
|
|
|
|
|
|
|
|
commands.spawn((
|
|
|
|
|
|
|
|
DebuggingState::On,
|
|
|
|
|
|
|
|
Name::new("Debug Indicator"),
|
|
|
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
|
|
|
children![Text(" Debug: ON ".into()),],
|
|
|
|
|
|
|
|
Node {
|
|
|
|
|
|
|
|
align_self: AlignSelf::Center,
|
|
|
|
|
|
|
|
justify_self: JustifySelf::End,
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Version string for troubleshooting
|
|
|
|
// Version string for troubleshooting
|
|
|
|
commands.spawn((
|
|
|
|
commands.spawn((
|
|
|
|
DebuggingState::On,
|
|
|
|
DebuggingState::On,
|
|
|
|
@ -94,37 +81,57 @@ fn init_debug_ui(mut commands: Commands) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
// Version string for troubleshooting
|
|
|
|
// "Turn on Debugging" button
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
DebuggingState::On,
|
|
|
|
|
|
|
|
Name::new("FPS"),
|
|
|
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
width: Val::Auto,
|
|
|
|
|
|
|
|
align_self: AlignSelf::Start,
|
|
|
|
align_self: AlignSelf::Start,
|
|
|
|
justify_self: JustifySelf::End,
|
|
|
|
justify_self: JustifySelf::End,
|
|
|
|
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
DebuggingState::Off,
|
|
|
|
|
|
|
|
Name::new("Debug Indicator"),
|
|
|
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
|
|
|
children![Text("Debug: OFF".into()),],
|
|
|
|
|
|
|
|
Button,
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.with_children(|parent| {
|
|
|
|
.observe(toggle_debug);
|
|
|
|
parent.spawn((Text::new("FPS: ##.#"), SyncResource::<Fps>::default()));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
DebuggingState::On,
|
|
|
|
DebuggingState::On,
|
|
|
|
Name::new("Entity Count"),
|
|
|
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
|
|
|
Node {
|
|
|
|
Node {
|
|
|
|
width: Val::Auto,
|
|
|
|
|
|
|
|
align_self: AlignSelf::Start,
|
|
|
|
align_self: AlignSelf::Start,
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
justify_self: JustifySelf::End,
|
|
|
|
|
|
|
|
flex_direction: FlexDirection::Column,
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.with_children(|parent| {
|
|
|
|
.with_children(|parent| {
|
|
|
|
|
|
|
|
parent
|
|
|
|
|
|
|
|
.spawn((
|
|
|
|
|
|
|
|
// Debug is active & button to toggle
|
|
|
|
|
|
|
|
DebuggingState::On,
|
|
|
|
|
|
|
|
Name::new("Debug Indicator"),
|
|
|
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
|
|
|
children![Text("Debug: ON".into()),],
|
|
|
|
|
|
|
|
Button,
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
.observe(toggle_debug);
|
|
|
|
parent.spawn((
|
|
|
|
parent.spawn((
|
|
|
|
|
|
|
|
// FPS Counter for troubleshooting
|
|
|
|
|
|
|
|
DebuggingState::On,
|
|
|
|
|
|
|
|
Name::new("FPS"),
|
|
|
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
|
|
|
Text::new("FPS: ##.#"),
|
|
|
|
|
|
|
|
SyncResource::<Fps>::default(),
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
parent.spawn((
|
|
|
|
|
|
|
|
// Entity count
|
|
|
|
|
|
|
|
DebuggingState::On,
|
|
|
|
|
|
|
|
Name::new("Entity Count"),
|
|
|
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
Text::new("Entities: ###"),
|
|
|
|
Text::new("Entities: ###"),
|
|
|
|
SyncResource::<EntityCount>::default(),
|
|
|
|
SyncResource::<EntityCount>::default(),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
@ -344,3 +351,15 @@ impl Display for EntityCount {
|
|
|
|
fn track_entity_count(query: Query<Entity>, mut count: ResMut<EntityCount>) {
|
|
|
|
fn track_entity_count(query: Query<Entity>, mut count: ResMut<EntityCount>) {
|
|
|
|
count.0 = query.iter().len();
|
|
|
|
count.0 = query.iter().len();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Toggle the debug state when a button is clicked
|
|
|
|
|
|
|
|
fn toggle_debug(
|
|
|
|
|
|
|
|
_trigger: Trigger<Pointer<Click>>,
|
|
|
|
|
|
|
|
curr: Res<State<DebuggingState>>,
|
|
|
|
|
|
|
|
mut next: ResMut<NextState<DebuggingState>>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
next.set(match curr.get() {
|
|
|
|
|
|
|
|
DebuggingState::On => DebuggingState::Off,
|
|
|
|
|
|
|
|
DebuggingState::Off => DebuggingState::On,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|