Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Question Updating character alpha and line spacing at the same time not possible?

Discussion in 'UGUI & TextMesh Pro' started by carcasanchez, Nov 12, 2021.

  1. carcasanchez

    carcasanchez

    Joined:
    Jul 15, 2018
    Posts:
    177
    Hi,
    Im trying to do a per-character fade in, and at the same time increase the character spacing over time.

    Code (CSharp):
    1.     IEnumerator FadeInText()
    2.     {
    3.         yield return new WaitForSeconds(0.4f);
    4.         float timer = 0;
    5.         while (timer < 10)
    6.         {
    7.            text.characterSpacing += spacingSpeed * Time.deltaTime;
    8.            text.UpdateVertexData(TMP_VertexDataUpdateFlags.Vertices);
    9.  
    10.             timer += Time.deltaTime;
    11.             for (int i = 0; i < text.text.Length; ++i)
    12.             {
    13.                 if (timer >= charTimes[i])
    14.                 {
    15.                     charDeltas[i] += Time.deltaTime;
    16.                     SetCharAlpha(text.textInfo, i, Mathf.Lerp(0, 255, charDeltas[i] / characterFadeTime));
    17.                 }
    18.             }
    19.             text.UpdateVertexData(TMP_VertexDataUpdateFlags.Colors32);
    20.             yield return null;
    21.         }
    22.     }
    However, there is a curious problem. Separatedly, all two effects work well, but when doing at the same time, the fade updating is not happening, only the spacing.
    I have tried to use UpdateVertexData(TMP_VertexDataUpdateFlags.All), and still the same issue. What is happening?