Struct bevy_screen_diags::ScreenDiagsState
source · pub struct ScreenDiagsState {
pub timer: Timer,
pub update_now: bool,
}
Expand description
The diagnostics state resource.
To disable the FPS rate, get a ResMut reference to this struct and pause the timer. Unpause the timer to re-enable the rate.
Fields§
§timer: Timer
The timer that triggers a diagnostics reading.
Disabling the timer disables the collection of the diagnostics and stops the display.
This is public, to allow flexible use, but in general you should use the methods [enable] and [disable] to interact with it.
update_now: bool
A flag to indicate to update the display, even if the timer has not popped.
This is public, to allow flexible use, but in general you should use the methods [enable] and [disable] to interact with it.
Implementations§
source§impl ScreenDiagsState
impl ScreenDiagsState
sourcepub fn enable(&mut self)
pub fn enable(&mut self)
Enable the FPS collection and display.
Examples found in repository?
examples/basic.rs (line 35)
27 28 29 30 31 32 33 34 35 36 37 38
fn mouse_handler(
mouse_button_input: Res<Input<MouseButton>>,
mut diags_state: ResMut<ScreenDiagsState>,
) {
if mouse_button_input.just_released(MouseButton::Left) {
if diags_state.enabled() {
diags_state.disable();
} else {
diags_state.enable();
}
}
}
More examples
examples/user_text.rs (line 45)
37 38 39 40 41 42 43 44 45 46 47 48
fn mouse_handler(
mouse_button_input: Res<Input<MouseButton>>,
mut diags_state: ResMut<ScreenDiagsState>,
) {
if mouse_button_input.just_released(MouseButton::Left) {
if diags_state.enabled() {
diags_state.disable();
} else {
diags_state.enable();
}
}
}
sourcepub fn disable(&mut self)
pub fn disable(&mut self)
Disable the FPS collection and display.
Examples found in repository?
examples/basic.rs (line 33)
27 28 29 30 31 32 33 34 35 36 37 38
fn mouse_handler(
mouse_button_input: Res<Input<MouseButton>>,
mut diags_state: ResMut<ScreenDiagsState>,
) {
if mouse_button_input.just_released(MouseButton::Left) {
if diags_state.enabled() {
diags_state.disable();
} else {
diags_state.enable();
}
}
}
More examples
examples/user_text.rs (line 43)
37 38 39 40 41 42 43 44 45 46 47 48
fn mouse_handler(
mouse_button_input: Res<Input<MouseButton>>,
mut diags_state: ResMut<ScreenDiagsState>,
) {
if mouse_button_input.just_released(MouseButton::Left) {
if diags_state.enabled() {
diags_state.disable();
} else {
diags_state.enable();
}
}
}
sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Whether the FPS collection and display enabled.
Examples found in repository?
examples/basic.rs (line 32)
27 28 29 30 31 32 33 34 35 36 37 38
fn mouse_handler(
mouse_button_input: Res<Input<MouseButton>>,
mut diags_state: ResMut<ScreenDiagsState>,
) {
if mouse_button_input.just_released(MouseButton::Left) {
if diags_state.enabled() {
diags_state.disable();
} else {
diags_state.enable();
}
}
}
More examples
examples/user_text.rs (line 42)
37 38 39 40 41 42 43 44 45 46 47 48
fn mouse_handler(
mouse_button_input: Res<Input<MouseButton>>,
mut diags_state: ResMut<ScreenDiagsState>,
) {
if mouse_button_input.just_released(MouseButton::Left) {
if diags_state.enabled() {
diags_state.disable();
} else {
diags_state.enable();
}
}
}
Trait Implementations§
source§impl Default for ScreenDiagsState
impl Default for ScreenDiagsState
impl Resource for ScreenDiagsStatewhere Self: Send + Sync + 'static,
Auto Trait Implementations§
impl RefUnwindSafe for ScreenDiagsState
impl Send for ScreenDiagsState
impl Sync for ScreenDiagsState
impl Unpin for ScreenDiagsState
impl UnwindSafe for ScreenDiagsState
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates
Self
using data from the given [World]