Search Unity

Get line break from UI.Text

Discussion in 'Scripting' started by fogman, Jan 29, 2015.

  1. fogman

    fogman

    Joined:
    Jan 21, 2009
    Posts:
    71
    Hi there,

    we need to export strings from UI.Text components to a file.
    The strings have some line breaks, introduced through the Enter-Key when writing the text into the fields.
    But when we read / export the strings, no line feeds (\n) are generated.

    How can we get the positions of the line breaks, so that we can manually insert \n at the right positions in the strings?

    Thanks in advance,

    Torsten
     
  2. fogman

    fogman

    Joined:
    Jan 21, 2009
    Posts:
    71
    Found it! Quite easy:

    string.Replace("\n", "\\n");