Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Second text overlays the first in Textbox using TextMesh Pro

Discussion in 'UGUI & TextMesh Pro' started by TheOtherJoJo, Jan 19, 2021.

  1. TheOtherJoJo

    TheOtherJoJo

    Joined:
    Apr 5, 2015
    Posts:
    14
    During some testing I wrote text to a textbox and then I want to replace that text with another and I get the second set of text on top of the first.
    It is working perfectly in Scene view but in the game view it overlays.

    Code (CSharp):
    1.    
    2. private void Start()
    3.     {
    4.         sb  = new StringBuilder(15);
    5.         StartCoroutine("FirstMessage");
    6.         StartCoroutine("SecondMessage");
    7.     }
    8.  
    9.  
    10.     //do start coroutines to set text
    11.  
    12.  
    13.     IEnumerator FirstMessage()
    14.     {
    15.         yield return new WaitForSeconds(2f);
    16.        // equationArea.SetText("First Message");
    17.         equationArea.text = "FirstMessage";
    18.     }
    19.  
    20.     IEnumerator SecondMessage()
    21.     {
    22.         yield return new WaitForSeconds(5f);
    23.         equationArea.text = "Second Message";
    24.  
    25.     }
    scrnshot.png
     
  2. TheOtherJoJo

    TheOtherJoJo

    Joined:
    Apr 5, 2015
    Posts:
    14
    I was able to find a workaround.
    The solution was to make the text object a child of an image object.
     
  3. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Based on your initial post, this seems like you have a hidden char(13) <CR> carriage return in your text. This would cause the text to be appear on top of the first but does not explain the difference between scene view and game view.

    So although I never replied to your initial post, this seems strange to me. Could you please provide me with a simple project that would enable me to take a closer look at this?

    You could upload the project somewhere and provide a link or just submit a bug report and post the Case # once you have it.

    I just want to make sure everything is behaving as expected :)