Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: soulburner on May 04, 2017, 11:48:51 AM

Title: UILabel text wrap + BBCodes
Post by: soulburner on May 04, 2017, 11:48:51 AM
It seems that something was changed last year.

My problem is that NGUI's text wrapping algoryth now breaks lines in place of [ ]  bb-codes.

I'm using moving [00000000] to make a typewriter effect in a speech bubble, so the text field stays constant size.

Like that:

Quote
Some dialog line is pr[00000000]inting here...

The problem is that this text can be wrapped the following way:
Quote
Some dialog line is pr
inting here...

Which I don't need.

Is there any way to make a word "pr[00000000]inting" unbreakable during wrapping?


PS: I've used the same effect some time ago (a year or more) in the previous version of NGUI and that didn't occur.
Title: Re: UILabel text wrap + BBCodes
Post by: ArenMook on May 04, 2017, 05:06:02 PM
Doesn't seem to happen on my end. I made a new scene, new label with text, made sure it has enough text to wrap around to the second line. I then put a typewriter script on it with a fade in time and hit Play. It remained wrapped. Can you provide more details as to how to repro this issue?
Title: Re: UILabel text wrap + BBCodes
Post by: soulburner on May 05, 2017, 05:25:20 AM
Just made a new project and imported the latest version of NGUI.

Created a text field with text:
Quote
Some text goes here not[ff0000]wrappableshouldbe.

(http://i.imgur.com/wIYtGMH.png)

The result is:

(http://i.imgur.com/PnBW8Bg.png)

My wish is that it should not be able to break the line after "not".

PS: I've imported a NGUIText.cs from some version one year old and it works just like I want:
(http://i.imgur.com/SPAiMZj.png)
Title: Re: UILabel text wrap + BBCodes
Post by: MigrantP on May 07, 2017, 11:00:24 PM
Perhaps this is related to the bug I reported here:
http://www.tasharen.com/forum/index.php?topic=15230.0
Title: Re: UILabel text wrap + BBCodes
Post by: ArenMook on May 13, 2017, 11:52:08 AM
Got it, thanks. You can fix it by editing NGUIText's WrapText function, line 1237:
  1. // When encoded symbols such as [RrGgBb] or [-] are encountered, skip past them
  2. if (encoding && ParseSymbol(text, ref offset, mColors, premultiply, ref subscriptMode, ref bold,
  3.         ref italic, ref underline, ref strikethrough, ref ignoreColor))
To:
  1. // When encoded symbols such as [RrGgBb] or [-] are encountered, skip past them
  2. if (encoding && ParseSymbol(text, ref offset, mColors, premultiply, ref subscriptMode, ref bold,
  3.         ref italic, ref underline, ref strikethrough, ref ignoreColor) && (offset == textLength || IsSpace(text[offset])))

Edit: Nevermind upon further testing this causes other issues. If the old NGUIText.cs works for you, just use it.
Title: Re: UILabel text wrap + BBCodes
Post by: soulburner on May 16, 2017, 06:36:21 AM
Thanks!