Open shifatkhan opened 4 years ago
Wrote an extra for
loop that runs when an opening <
symbol is found. Adds the found tag as a string to the TextMesh text (instead of one character at a time)
if(textToType[i] == '<')
{
string richtext = "";
for (int j = i; j < textToType.Length; j++)
{
richtext += textToType[j];
if(textToType[j] == '>')
{
i = j+1;
textMesh.text += richtext;
break;
}
}
}
Simply fixed it by stopping all coroutine before starting a new dialogue with StopAllCoroutines()
Right now, the TextMeshAnimator
animates the letters once the Typewriter is done.
Need to make it so the text animations play on the characters that are drawn already on screen.
Combined Typewriter effect with TextMeshAnimator's animations, but it is a bit glitchy. The text moves very slightly when typing, but the actual animations starts playing the the typewriter is done.
I am calling textMeshAnimator.SyncToTextMesh()
after each typed character:
IEnumerator Typewriter()
{
for (int i = 0; i < textToType.Length; i++)
{
// Check for rich text. Skip them so typewriter effect doesn't apply.
if(textToType[i] == '<')
{
string richtext = "";
for (int j = i; j < textToType.Length; j++)
{
richtext += textToType[j];
if(textToType[j] == '>')
{
// Hotfix for index out of bounds when we do i = j+1
if (j + 1 >= textToType.Length)
textToType += " ";
i = j+1;
textMesh.text += richtext;
break;
}
}
}
textMesh.text += textToType[i];
textMeshAnimator.SyncToTextMesh(); // *HERE
yield return new WaitForSeconds(typingSpeed);
}
finishedTyping = true;
}
Need to find a way to call textMeshAnimator.SyncToTextMesh()
efficiently
coroutine
finished, it would result in both dialogue texts getting mixed together