Hello, I am currently working on a project where we want text to teletype in. To do this we are making use of the mesh generated by TMPro and updating the alpha on the vertex colors.
This is the text that I am trying to manipulate: Chracter Name: Here is some sample text you’re going to read in the game. To hide and teletype this text we are going through two steps, first, set all the alphas to 0, then make a coroutine for each character where each one waits a set amount of time it’s supposed to until it should reveal.
My problems seem to mainly stem from part 1. If all I do is set the alpha to 0 this is the string I can see in game : Chracter Name: [SPACING] ’ [SPACING]
So as you can see, the character name is not hidden, but still comes through bold, and the apostrophe is still visible as well. It is worth noting that no other punctuation is visible.
Here is the code I am using to hide the characters.
m_TextComponent.ForceMeshUpdate();
TMP_TextInfo textInfo = m_TextComponent.textInfo;
int charCount = textInfo.characterCount;
for (int i = 0; i < charCount; ++i)
{
TMP_CharacterInfo charInfo = textInfo.characterInfo[i];
if (!charInfo.isVisible)
{
print(charInfo.character);
continue;
}
int index = charInfo.vertexIndex;
for (int j = 0; j < 4; ++j)
{
m_TextComponent.textInfo.meshInfo[0].colors32[index + j].a = startAlpha;
}
}
textInfo.meshInfo[0].mesh.vertices = textInfo.meshInfo[0].vertices;
m_TextComponent.UpdateVertexData();
As you can see I am also printing all of the characters that are not visible and I receive nothing but ’ ’ (space characters) from this output.
It is in step 2, where I reveal the characters one at a time, that I see another oddity that seems related to part 1. I start a coroutine, where I pass the vertex index, and the coroutine will update the alpha value at the given index.This works very well for all but the first few letters, as it seems to do the first 4 letters twice. I believe this is the case because the $CharacterName that I am using is CEO: so the first message looks something like this:
CEO: Welcome!
When this runs, I see CEO: in bold from the start, they are never invisible, and then right away W comes in, then e, l, c, It pauses, as it redoes W, e, l, c then proceeds on to the rest of the message.
Because this is the case, it seems to me that the CEO portion seems to be getting excluded from the mesh vertices or something of the like and I am unable to figure out what it is I am doing wrong or how I would properly handle a case such as this, I also still do not understand why the ’ is also visible from the start.