Merge branch 'main' into port-gltf-examples
This commit is contained in:
commit
244db91f49
@ -71,14 +71,14 @@ log = { version = "0.4", default-features = false }
|
||||
# macOS
|
||||
[target.'cfg(all(target_os="macos"))'.dependencies]
|
||||
# Some features of sysinfo are not supported by apple. This will disable those features on apple devices
|
||||
sysinfo = { version = "0.35.0", optional = true, default-features = false, features = [
|
||||
sysinfo = { version = "0.36.0", optional = true, default-features = false, features = [
|
||||
"apple-app-store",
|
||||
"system",
|
||||
] }
|
||||
|
||||
# Only include when on linux/windows/android/freebsd
|
||||
[target.'cfg(any(target_os = "linux", target_os = "windows", target_os = "android", target_os = "freebsd"))'.dependencies]
|
||||
sysinfo = { version = "0.35.0", optional = true, default-features = false, features = [
|
||||
sysinfo = { version = "0.36.0", optional = true, default-features = false, features = [
|
||||
"system",
|
||||
] }
|
||||
|
||||
|
@ -1,20 +1,39 @@
|
||||
use bevy_app::prelude::*;
|
||||
use bevy_ecs::entity::Entities;
|
||||
|
||||
use crate::{Diagnostic, DiagnosticPath, Diagnostics, RegisterDiagnostic};
|
||||
use crate::{
|
||||
Diagnostic, DiagnosticPath, Diagnostics, RegisterDiagnostic, DEFAULT_MAX_HISTORY_LENGTH,
|
||||
};
|
||||
|
||||
/// Adds "entity count" diagnostic to an App.
|
||||
///
|
||||
/// # See also
|
||||
///
|
||||
/// [`LogDiagnosticsPlugin`](crate::LogDiagnosticsPlugin) to output diagnostics to the console.
|
||||
#[derive(Default)]
|
||||
pub struct EntityCountDiagnosticsPlugin;
|
||||
pub struct EntityCountDiagnosticsPlugin {
|
||||
/// The total number of values to keep.
|
||||
pub max_history_length: usize,
|
||||
}
|
||||
|
||||
impl Default for EntityCountDiagnosticsPlugin {
|
||||
fn default() -> Self {
|
||||
Self::new(DEFAULT_MAX_HISTORY_LENGTH)
|
||||
}
|
||||
}
|
||||
|
||||
impl EntityCountDiagnosticsPlugin {
|
||||
/// Creates a new `EntityCountDiagnosticsPlugin` with the specified `max_history_length`.
|
||||
pub fn new(max_history_length: usize) -> Self {
|
||||
Self { max_history_length }
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for EntityCountDiagnosticsPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.register_diagnostic(Diagnostic::new(Self::ENTITY_COUNT))
|
||||
.add_systems(Update, Self::diagnostic_system);
|
||||
app.register_diagnostic(
|
||||
Diagnostic::new(Self::ENTITY_COUNT).with_max_history_length(self.max_history_length),
|
||||
)
|
||||
.add_systems(Update, Self::diagnostic_system);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ fn main() {
|
||||
// Adds frame time, FPS and frame count diagnostics.
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
// Adds an entity count diagnostic.
|
||||
EntityCountDiagnosticsPlugin,
|
||||
EntityCountDiagnosticsPlugin::default(),
|
||||
// Adds cpu and memory usage diagnostics for systems and the entire game process.
|
||||
SystemInformationDiagnosticsPlugin,
|
||||
// Forwards various diagnostics from the render app to the main app.
|
||||
|
Loading…
Reference in New Issue
Block a user