From 2dbe21ec62435ca23df0cee25b6204ef10fe999a Mon Sep 17 00:00:00 2001 From: Antoine Papillon Date: Fri, 13 Mar 2026 11:16:25 +0100 Subject: [PATCH] refactor: initialise int before the loop --- Assets/Code/Scripts/Level/SubtitleSequencePlayer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/Code/Scripts/Level/SubtitleSequencePlayer.cs b/Assets/Code/Scripts/Level/SubtitleSequencePlayer.cs index 7446f11..4ce8a9b 100644 --- a/Assets/Code/Scripts/Level/SubtitleSequencePlayer.cs +++ b/Assets/Code/Scripts/Level/SubtitleSequencePlayer.cs @@ -144,12 +144,13 @@ public class SubtitleSequencePlayer : MonoBehaviour float typeTime = 0f; int totalChars = line.text.Length; + int visibleChars = 0; if (typewriterCharsPerSecond > 0f) { while (m_currentText.Length < totalChars) { typeTime += Time.deltaTime; - int visibleChars = Mathf.Clamp(Mathf.FloorToInt(typeTime * typewriterCharsPerSecond), 0, totalChars); + visibleChars = Mathf.Clamp(Mathf.FloorToInt(typeTime * typewriterCharsPerSecond), 0, totalChars); m_currentText = line.text.Substring(0, visibleChars); yield return null; }