Hi, I am making a dialogue system for a game and have run into a weird performance/rendering issue. Basically, I am trying to print a sentence to the screen letter by letter to get the “typing” effect. I made a script that did that and it worked perfectly as intended.
Now, when I started up Unity again without doing any changes what so ever, it stopped working. I checked that the code was fine and it totally is. I also noticed that the text window on the TextMeshPro component in the inspector was updating like it should, letter by letter.
That’s when I thought it might be some performance issue when updating text rapidly, but to my surprise, when I turned the typing speed way down, it was still not updating before the entire sentence was typed out. (see video)
Here is the coroutine that updates the text:
IEnumerator TypeSentence(string sentence)
{
string currentTypedSentence = "";
nextButton.SetActive(false);
foreach (char letter in sentence)
{
currentTypedSentence = currentTypedSentence + letter;
if (currentTypedSentence == sentence)
{
nextButton.SetActive(true);
}
textSource.SetText(currentTypedSentence);
yield return new WaitForSeconds(typingSpeed);
}
}
Here is a video that shows the problem in action:
Notice that the inspector is updating as it should.
Does anyone know what is causing this behavior? Thanks in advance!
Update:
It just started to work again out of the blue for a minute, and then back to not working…