Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

TextMesh Pro (Fixed) TextMeshPro text new line via script?

Discussion in 'UGUI & TextMesh Pro' started by Protozoaire, Sep 24, 2018.

  1. Protozoaire

    Protozoaire

    Joined:
    Apr 14, 2015
    Posts:
    62
    When I try to make a new line on a TextMeshPro, it's displaying "\n" instead of a new line.

    EDIT: To make a new line, just do this: TheString.Replace("\\n", "\n");
     
    Last edited: Sep 24, 2018
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    This should work fine provided the string is defined in code and not in a public field.

    See the following thread for a detailed explanation.
     
    Protozoaire likes this.
  3. Protozoaire

    Protozoaire

    Joined:
    Apr 14, 2015
    Posts:
    62
    Yes, it was not a good example.
    What I do is getting the text on a server, it contains "sometext\nsometext".
    So the whole text is considered as text by Unity.

    => So, to make a new line, I just have to do this: TheString.Replace("\\n", "\n");
     
    Dave_Bowman and AM-Dev like this.