diff --git a/Assets/Fungus/Scripts/Components/Writer.cs b/Assets/Fungus/Scripts/Components/Writer.cs index b0015dbb..6052b34e 100644 --- a/Assets/Fungus/Scripts/Components/Writer.cs +++ b/Assets/Fungus/Scripts/Components/Writer.cs @@ -495,6 +495,7 @@ namespace Fungus UpdateCloseMarkup(); float timeAccumulator = Time.deltaTime; + float invWritingSpeed = 1f / currentWritingSpeed; for (int i = 0; i < param.Length + 1; ++i) { @@ -510,6 +511,7 @@ namespace Fungus yield return null; } + //actually grab the next chars PartitionString(writeWholeWords, param, i); ConcatenateString(startText); textAdapter.Text = outputString.ToString(); @@ -533,13 +535,19 @@ namespace Fungus // Delay between characters if (currentWritingSpeed > 0f) { - if (timeAccumulator > 0f) + timeAccumulator -= invWritingSpeed; + if (timeAccumulator <= 0f) { - timeAccumulator -= 1f / currentWritingSpeed; - } - else - { - yield return new WaitForSeconds(1f / currentWritingSpeed); + if (invWritingSpeed > Time.deltaTime) + { + yield return new WaitForSeconds(invWritingSpeed); + timeAccumulator += invWritingSpeed; + } + else + { + yield return null; + timeAccumulator += Time.deltaTime; + } } } }