Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

TextMesh Pro Textmeshpro Text alpha does not react to new alpha assigned over time [Solved]

Discussion in 'Unity UI & TextMesh Pro' started by simonlvschal, Nov 8, 2018.

  1. simonlvschal

    simonlvschal

    Joined:
    Nov 17, 2015
    Posts:
    261
    so as title suggest i am trying to make textmeshpro alpha change over time. but for some reason it doesn't exaclty do this.

    instead of going from 0-1 or 0-255 it does so instantly.

    this is the corutine

    Code (CSharp):
    1.  
    2. protected IEnumerator ShowZoneName(string zoneName,TextMeshProUGUI textMeshProUGUI,GameObject gameObject)
    3.     {
    4.         float t = 0;
    5.         Color startColor = new Color(255,255,255,0);
    6.         Color endColor = new Color(255,255,255,255);
    7.  
    8.         textMeshProUGUI.color = startColor;
    9.         textMeshProUGUI.text = zoneName;
    10.      
    11.         while (t < 1)
    12.         {
    13.             textMeshProUGUI.color = Color.Lerp(startColor, endColor, t);
    14.             t += Time.deltaTime / 5f;
    15.             Debug.Log(t);
    16.             yield return null;
    17.         }
    18.      
    19.     }

    Never mind solved it. i had to use Color32 instead
     
    Last edited: Nov 8, 2018
    Stephan_B likes this.