diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-10-09 10:57:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-09 10:57:56 +0200 |
commit | ab5e7d1b864c711849681a182909434fb10a2137 (patch) | |
tree | 2dd8c932742ee739066c7df8a9a7be22c4629e95 /scene | |
parent | 1fd440f5afb4343411c4cb412569edd198827db6 (diff) | |
parent | 42d13e29e2813ee833fa209cfd0e9b379cb84cd9 (diff) |
Merge pull request #53589 from Calinou/timer-low-wait-time-add-warning
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/timer.cpp | 11 | ||||
-rw-r--r-- | scene/main/timer.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 9e462eb1c8..154e4cf683 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -82,6 +82,7 @@ void Timer::_notification(int p_what) { void Timer::set_wait_time(double p_time) { ERR_FAIL_COND_MSG(p_time <= 0, "Time should be greater than zero."); wait_time = p_time; + update_configuration_warnings(); } double Timer::get_wait_time() const { @@ -179,6 +180,16 @@ void Timer::_set_process(bool p_process, bool p_force) { processing = p_process; } +TypedArray<String> Timer::get_configuration_warnings() const { + TypedArray<String> warnings = Node::get_configuration_warnings(); + + if (wait_time < 0.05 - CMP_EPSILON) { + warnings.push_back(TTR("Very low timer wait times (< 0.05 seconds) may behave in significantly different ways depending on the rendered or physics frame rate.\nConsider using a script's process loop instead of relying on a Timer for very low wait times.")); + } + + return warnings; +} + void Timer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_wait_time", "time_sec"), &Timer::set_wait_time); ClassDB::bind_method(D_METHOD("get_wait_time"), &Timer::get_wait_time); diff --git a/scene/main/timer.h b/scene/main/timer.h index 2b9faddcb9..e2f34042dd 100644 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -73,6 +73,8 @@ public: double get_time_left() const; + TypedArray<String> get_configuration_warnings() const override; + void set_timer_process_callback(TimerProcessCallback p_callback); TimerProcessCallback get_timer_process_callback() const; Timer(); |