|
|
|
@ -13,6 +13,7 @@ impl Plugin for DebuggingPlugin {
|
|
|
|
.init_resource::<ToolTip>()
|
|
|
|
.init_resource::<ToolTip>()
|
|
|
|
.init_resource::<Fps>()
|
|
|
|
.init_resource::<Fps>()
|
|
|
|
.init_resource::<EntityCount>()
|
|
|
|
.init_resource::<EntityCount>()
|
|
|
|
|
|
|
|
.init_resource::<WindowInfo>()
|
|
|
|
.init_resource::<Notice>()
|
|
|
|
.init_resource::<Notice>()
|
|
|
|
.add_systems(Startup, init_debug_ui)
|
|
|
|
.add_systems(Startup, init_debug_ui)
|
|
|
|
.add_systems(
|
|
|
|
.add_systems(
|
|
|
|
@ -33,7 +34,9 @@ impl Plugin for DebuggingPlugin {
|
|
|
|
track_fps,
|
|
|
|
track_fps,
|
|
|
|
sync_resource_to_ui::<Fps>.run_if(resource_changed::<Fps>),
|
|
|
|
sync_resource_to_ui::<Fps>.run_if(resource_changed::<Fps>),
|
|
|
|
track_entity_count,
|
|
|
|
track_entity_count,
|
|
|
|
|
|
|
|
track_window_info.run_if(any_component_changed::<Window>),
|
|
|
|
sync_resource_to_ui::<EntityCount>.run_if(resource_changed::<EntityCount>),
|
|
|
|
sync_resource_to_ui::<EntityCount>.run_if(resource_changed::<EntityCount>),
|
|
|
|
|
|
|
|
sync_resource_to_ui::<WindowInfo>.run_if(resource_changed::<WindowInfo>),
|
|
|
|
sync_resource_to_ui::<Notice>.run_if(resource_changed::<Notice>),
|
|
|
|
sync_resource_to_ui::<Notice>.run_if(resource_changed::<Notice>),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.run_if(in_state(DebuggingState::On)),
|
|
|
|
.run_if(in_state(DebuggingState::On)),
|
|
|
|
@ -170,6 +173,15 @@ fn init_debug_ui(mut commands: Commands) {
|
|
|
|
TextColor(BLACK.into()),
|
|
|
|
TextColor(BLACK.into()),
|
|
|
|
SyncResource::<EntityCount>::default(),
|
|
|
|
SyncResource::<EntityCount>::default(),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
parent.spawn((
|
|
|
|
|
|
|
|
// Window info
|
|
|
|
|
|
|
|
DebuggingState::On,
|
|
|
|
|
|
|
|
Name::new("Window Info"),
|
|
|
|
|
|
|
|
GlobalZIndex(i32::MAX - 1),
|
|
|
|
|
|
|
|
Text::new("Window Info..."),
|
|
|
|
|
|
|
|
TextColor(BLACK.into()),
|
|
|
|
|
|
|
|
SyncResource::<WindowInfo>::default(),
|
|
|
|
|
|
|
|
));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Tooltip
|
|
|
|
// Tooltip
|
|
|
|
@ -492,6 +504,33 @@ fn track_entity_count(query: Query<Entity>, mut count: ResMut<EntityCount>) {
|
|
|
|
count.0 = query.iter().len();
|
|
|
|
count.0 = query.iter().len();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Resource, Default, Debug)]
|
|
|
|
|
|
|
|
struct WindowInfo {
|
|
|
|
|
|
|
|
logical_size: (f32, f32),
|
|
|
|
|
|
|
|
physical_size: (f32, f32),
|
|
|
|
|
|
|
|
scale_factor: f32,
|
|
|
|
|
|
|
|
mode: String,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Display for WindowInfo {
|
|
|
|
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
|
|
|
|
writeln!(
|
|
|
|
|
|
|
|
f,
|
|
|
|
|
|
|
|
"Res (Logi): {:?}\nRes (Phys): {:?}\nWindow Scale: {}\nWindow Mode: {}",
|
|
|
|
|
|
|
|
self.logical_size, self.physical_size, self.scale_factor, self.mode
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn track_window_info(window: Single<&Window>, mut info: ResMut<WindowInfo>) {
|
|
|
|
|
|
|
|
(info.logical_size.0, info.logical_size.1) =
|
|
|
|
|
|
|
|
(window.resolution.size().x, window.resolution.size().y);
|
|
|
|
|
|
|
|
(info.physical_size.0, info.physical_size.1) =
|
|
|
|
|
|
|
|
(window.resolution.size().x, window.resolution.size().y);
|
|
|
|
|
|
|
|
info.scale_factor = window.resolution.scale_factor();
|
|
|
|
|
|
|
|
info.mode = format!("{:?}", window.mode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Toggle the debug state when a button is clicked
|
|
|
|
/// Toggle the debug state when a button is clicked
|
|
|
|
fn toggle_debug(
|
|
|
|
fn toggle_debug(
|
|
|
|
_trigger: Trigger<Pointer<Click>>,
|
|
|
|
_trigger: Trigger<Pointer<Click>>,
|
|
|
|
|