From a0691868d88c89c2dd9d67f6c4e4ccb6a84d3883 Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Sun, 30 Oct 2022 16:02:31 +0000 Subject: [PATCH] Add FromReflect for Timer (#6422) # Objective - Time have `Reflect`, but doesn't have `FromReflect`. ## Solution - Add it for `Timer`, `Stopwatch` and `TimerMode`. --- ## Changelog ### Added * `FromReflect` derive for `Timer`, `Stopwatch` and `TimerMode`. --- crates/bevy_time/src/stopwatch.rs | 2 +- crates/bevy_time/src/timer.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_time/src/stopwatch.rs b/crates/bevy_time/src/stopwatch.rs index 2dd925e4efb559..dcc0cfb9f29695 100644 --- a/crates/bevy_time/src/stopwatch.rs +++ b/crates/bevy_time/src/stopwatch.rs @@ -23,7 +23,7 @@ use bevy_utils::Duration; /// assert!(stopwatch.paused()); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); /// ``` -#[derive(Clone, Debug, Default, Reflect)] +#[derive(Clone, Debug, Default, Reflect, FromReflect)] #[cfg_attr(feature = "serialize", derive(serde::Deserialize, serde::Serialize))] #[reflect(Default)] pub struct Stopwatch { diff --git a/crates/bevy_time/src/timer.rs b/crates/bevy_time/src/timer.rs index 2aa983400e1611..1ed613df9195ca 100644 --- a/crates/bevy_time/src/timer.rs +++ b/crates/bevy_time/src/timer.rs @@ -9,7 +9,7 @@ use bevy_utils::Duration; /// exceeded, and can still be reset at any given point. /// /// Paused timers will not have elapsed time increased. -#[derive(Clone, Debug, Default, Reflect)] +#[derive(Clone, Debug, Default, Reflect, FromReflect)] #[cfg_attr(feature = "serialize", derive(serde::Deserialize, serde::Serialize))] #[reflect(Default)] pub struct Timer { @@ -403,7 +403,7 @@ impl Timer { } /// Specifies [`Timer`] behavior. -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default, Reflect)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default, Reflect, FromReflect)] #[cfg_attr(feature = "serialize", derive(serde::Deserialize, serde::Serialize))] #[reflect(Default)] pub enum TimerMode {