From 7a40c2f8299b0d23b2ee0747ef9ebc8f15eb694b Mon Sep 17 00:00:00 2001 From: Steve Halliwell Date: Mon, 17 Aug 2020 16:59:05 +1000 Subject: [PATCH] Add PuncPause and NotifyGlyph to TMPro Writer Fix #845 --- Assets/Fungus/Scripts/Components/Writer.cs | 11 ++++++++++- Assets/Fungus/Scripts/Utils/TextAdapter.cs | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Scripts/Components/Writer.cs b/Assets/Fungus/Scripts/Components/Writer.cs index 019ff519..6e2d40d0 100644 --- a/Assets/Fungus/Scripts/Components/Writer.cs +++ b/Assets/Fungus/Scripts/Components/Writer.cs @@ -584,7 +584,16 @@ namespace Fungus } textAdapter.RevealedCharacters++; - + + NotifyGlyph(); + //TODO need to log some info here, it's not a perf spike + + // Punctuation pause + if (IsPunctuation(textAdapter.LastRevealedCharacter)) + { + yield return StartCoroutine(DoWait(currentPunctuationPause)); + } + if (currentWritingSpeed > 0f) { timeAccumulator -= invWritingSpeed; diff --git a/Assets/Fungus/Scripts/Utils/TextAdapter.cs b/Assets/Fungus/Scripts/Utils/TextAdapter.cs index 34f2f188..0e357792 100644 --- a/Assets/Fungus/Scripts/Utils/TextAdapter.cs +++ b/Assets/Fungus/Scripts/Utils/TextAdapter.cs @@ -233,6 +233,20 @@ namespace Fungus } } + public char LastRevealedCharacter + { + get + { +#if UNITY_2018_1_OR_NEWER + if(tmpro != null) + { + return tmpro.textInfo.characterInfo[tmpro.maxVisibleCharacters].character; + } +#endif + return (char)0; + } + } + public int CharactersToReveal { get