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

UI.Text and blank space

Discussion in 'UGUI & TextMesh Pro' started by StudCortex, May 26, 2015.

  1. StudCortex

    StudCortex

    Joined:
    Feb 25, 2015
    Posts:
    9
    Hi

    I'm working with text chunks and need to preserve the end line blank space in my text in order to display them correctly on screen. As words are made out of several chunks of text, I can't use the position or the layout's spacing to do this.
    By default, Unity seems to delete the last characters if they are blank space, anyone has an idea of what to do to avoid this ?
     
  2. StudCortex

    StudCortex

    Joined:
    Feb 25, 2015
    Posts:
    9
    Using non breakable space solved the problem.
    I first tried with &nbsp, you actually have to use the following in order to see a blank space at the end of your UI.text :

    Code (CSharp):
    1. text = text.Replace(' ', (char)160);
     
    radiatoryang likes this.