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

Strange problem with Input Field (don't work the same as in the Editor)

Discussion in 'UGUI & TextMesh Pro' started by panicq, Jul 1, 2015.

  1. panicq

    panicq

    Joined:
    Sep 29, 2012
    Posts:
    37
    Hi,

    I've a pretty strange problem on an InputField: When I press the Return key in order to validate it, a '\n' character is added to the end of the text. As I'm doing a chat system it's pretty anoying. However, the '\n' don't appears when I am testing my game in the editor. My InputField has the Single Line option. And I'm on a mac.

    Do you have any idea ?
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Don't know why it happens, but here's your answer:
    Code (CSharp):
    1. myString = myString.Remove ("\n");
     
  3. panicq

    panicq

    Joined:
    Sep 29, 2012
    Posts:
    37
    Thank you, I've done a similar thing:

    Code (CSharp):
    1. msg = msg.Replace("\n", "");
    But it's still annoying...