I got this simple script working fine with TextMeshPro following this tutorial, but TextMeshProUGUI completely ignores the vertices pushed to TextMeshProUGUI.mesh.vertices.
IEnumerator Animate()
{
var TMPtext = GetComponent<TextMeshProUGUI>();
TMPtext.ForceMeshUpdate();
Vector3[] vertices;
Matrix4x4 matrix;
for (int i = 0; i < TMPtext.textInfo.characterCount; i++)
{
var vert = TMPtext.textInfo.characterInfo[i];
if (!vert.isVisible)
continue;
vertices = TMPtext.mesh.vertices;
var vertexIndex = vert.vertexIndex;
matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, 30f), Vector3.one);
var pos = transform.position;
vertices[vertexIndex + 0] = matrix.MultiplyPoint3x4(vertices[vertexIndex + 0]);
vertices[vertexIndex + 1] = matrix.MultiplyPoint3x4(vertices[vertexIndex + 1]);
vertices[vertexIndex + 2] = matrix.MultiplyPoint3x4(vertices[vertexIndex + 2]);
vertices[vertexIndex + 3] = matrix.MultiplyPoint3x4(vertices[vertexIndex + 3]);
TMPtext.mesh.vertices = vertices;
yield return new WaitForSeconds(0.1f);
}
}
These are the components on the GameObject:
Here’s a video sample of this code running.
What am I doing wrong?
Any pointers are much appreciated!