Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    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:
    247
    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.