diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-03-08 10:30:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 10:30:50 +0100 |
commit | d52974ba953ff01b3f8199977fbc582f5bcc843e (patch) | |
tree | d6ef4af797e563ff862ca4eb72a4618f3ef46a11 | |
parent | 9a33c1b6a6615ffa703a9a28c8c7be6b7cf5a4db (diff) | |
parent | 3bd44f3cb6b2e34983909128c768ebb77602e882 (diff) |
Merge pull request #46776 from jmb462/fix-label-visible_characters_bad_precision
fix Label visible_characters bad precision (Fix #46775)
-rw-r--r-- | scene/gui/label.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index b98caf3562..be73fd8f51 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -260,7 +260,8 @@ void Label::_notification(int p_what) { } } } - visible_glyphs = total_glyphs * percent_visible; + + visible_glyphs = MIN(total_glyphs, visible_chars); } Vector2 ofs; @@ -541,6 +542,8 @@ void Label::set_visible_characters(int p_amount) { visible_chars = p_amount; if (get_total_character_count() > 0) { percent_visible = (float)p_amount / (float)get_total_character_count(); + } else { + percent_visible = 1.0; } update(); } |