From dbce96abd9292a3b6a1b9d69f1cff4f9e77f2a1d Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 20 Sep 2022 12:49:47 +0200 Subject: [PATCH] Don't store frame of playing AnimatedSprite --- scene/2d/animated_sprite.cpp | 6 ++++++ scene/3d/sprite_3d.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 8c709aba4f9..a27df545f04 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -347,6 +347,11 @@ void AnimatedSprite::_validate_property(PropertyInfo &property) const { } if (property.name == "frame") { + if (playing) { + property.usage = PROPERTY_USAGE_EDITOR; + return; + } + property.hint = PROPERTY_HINT_RANGE; if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) { property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1"; @@ -590,6 +595,7 @@ void AnimatedSprite::set_playing(bool p_playing) { playing = p_playing; _reset_timeout(); set_process_internal(playing); + property_list_changed_notify(); } bool AnimatedSprite::is_playing() const { diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 22be5ae4c33..33d207bd0a9 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -987,6 +987,11 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { } if (property.name == "frame") { + if (playing) { + property.usage = PROPERTY_USAGE_EDITOR; + return; + } + property.hint = PROPERTY_HINT_RANGE; if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) { property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1"; @@ -1139,6 +1144,7 @@ void AnimatedSprite3D::_set_playing(bool p_playing) { playing = p_playing; _reset_timeout(); set_process_internal(playing); + property_list_changed_notify(); } bool AnimatedSprite3D::_is_playing() const {