I have been unable to find any other discussions about this. I’m writing a script that makes words fade in one at a time. So far it works great, but the “firstCharacterIndex” and “lastCharacterIndex” of “WordInfo” doesn’t seem to count any sort of punctuation such as colons, commas, or question marks.
To clarify, if the first “word” is “5:”, it will say the first and last letter of that word is 0 (the 5). Or if the last word is “Yes?” it will say the last word is a three letter word ending at the “s”.
I’ll go ahead and post my code if it’s any help to anyone.
private IEnumerator RollingText()
{
displayText.ForceMeshUpdate(true);
TMP_TextInfo textInfo = displayText.textInfo;
int wordCount = textInfo.wordCount;
Color32[] newVertexColors;
Color32 displayColor = displayText.color;
Color32 fullColor = new Color32(255, 255, 255, 255);
for (var i = 0; i < wordCount; i++)
{
TMP_WordInfo wordInfo = textInfo.wordInfo[i];
int wordStart = wordInfo.firstCharacterIndex;
int wordEnd = wordInfo.lastCharacterIndex;
for (int j = 0; j < 5; j++)
{
fullColor.a = (byte)(255*(j/5f));
displayColor = fullColor;
Debug.Log(j);
for (int k = wordStart; k <= wordEnd; k++)
{
int materialIndex = textInfo.characterInfo[k].materialReferenceIndex;
newVertexColors = textInfo.meshInfo[materialIndex].colors32;
int vertexIndex = textInfo.characterInfo[k].vertexIndex;
newVertexColors[vertexIndex + 0] = displayColor;
newVertexColors[vertexIndex + 1] = displayColor;
newVertexColors[vertexIndex + 2] = displayColor;
newVertexColors[vertexIndex + 3] = displayColor;
displayText.UpdateVertexData(TMP_VertexDataUpdateFlags.Colors32);
}
yield return null;
}
yield return null;
}
}