Search Unity

BUG: EditorGUILayout.TextField escapes the string.

Discussion in 'Editor & General Support' started by ishlilith, Apr 11, 2013.

  1. ishlilith

    ishlilith

    Joined:
    Mar 16, 2012
    Posts:
    13
    I have just spent several hours trying to find why string.Replace worked only sometimes so I'm posting this just in case someone runs into the same problem.

    If you have a string populated by EditorGUILayout.TextField using \n (or \t, etc...) in the editor escapes the "\" making replace or regexes useless, so instead of string.Replace("\n", "") use string.Replace("\\n", "")

    I understand that is to prevent "I wrote X but got Y" threads, but at last give us a toggle to return the exact same string we wrote.