diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-07-03 16:08:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-03 16:08:04 +0200 |
commit | 886020607afacd6eaab86154a947cb82f845823f (patch) | |
tree | c701c2f98e96e0b2dc653268965cac71349f707f | |
parent | b2a4cac9f434634dcb506afe47ce6831db3c12b9 (diff) | |
parent | 73ecd71b7d017612d5c6ab1dd4c180fd57bfe770 (diff) |
Merge pull request #62672 from kleonc/animated_sprite_fix_frame_hint_string_error
-rw-r--r-- | scene/2d/animated_sprite_2d.cpp | 5 | ||||
-rw-r--r-- | scene/3d/sprite_3d.cpp | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 221d52bc20..d56c7b8811 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -138,8 +138,11 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &property) const { if (property.name == "frame") { property.hint = PROPERTY_HINT_RANGE; - if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) { + if (frames->has_animation(animation) && frames->get_frame_count(animation) > 0) { property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1"; + } else { + // Avoid an error, `hint_string` is required for `PROPERTY_HINT_RANGE`. + property.hint_string = "0,0,1"; } property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; } diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 55b55d924c..cb6354f7a8 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -1034,8 +1034,11 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { if (property.name == "frame") { property.hint = PROPERTY_HINT_RANGE; - if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) { + if (frames->has_animation(animation) && frames->get_frame_count(animation) > 0) { property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1"; + } else { + // Avoid an error, `hint_string` is required for `PROPERTY_HINT_RANGE`. + property.hint_string = "0,0,1"; } property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; } |