Author Topic: Formatting characters behavior  (Read 4222 times)

Alessaint

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 67
    • View Profile
Formatting characters behavior
« on: July 03, 2013, 05:52:10 AM »
Hi,

I've just installed the latest version of NGUI and now I see "\n" displayed  in some of my texts where it originally created a new line. Did I miss anything in the changelog?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Formatting characters behavior
« Reply #1 on: July 03, 2013, 05:53:36 AM »
It was removed many months ago in order to eliminate an extra string.Replace happening every time label text gets assigned.

By the way, in your example "\n" should be "\\n" -- two characters. "\n" specified via code interprets as a single character -- a newline -- which works just fine.

Alessaint

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 67
    • View Profile
Re: Formatting characters behavior
« Reply #2 on: July 03, 2013, 06:04:59 AM »
Erm, I made my post a bit confusing. I meant simply \n - I added the quotation marks to make it stand out in the text.

I'm sorry but I think I don't quite follow what you're saying :)

To be more exact - I have a string read from an xml file that looks like this "HEADER\nBlah blah blah" and I assign to NGUIs label text. What can I do so that it works as it did before?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Formatting characters behavior
« Reply #3 on: July 03, 2013, 06:08:54 AM »
When you read your text from the XML file, before assigning it to your local variable do a string.Replace on it replacing "\\n" with "\n".

Alessaint

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 67
    • View Profile
Re: Formatting characters behavior
« Reply #4 on: July 03, 2013, 06:09:53 AM »
Oh, I see. Thanks.