Author Topic: UILabel text wrap + BBCodes  (Read 7346 times)

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
UILabel text wrap + BBCodes
« 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.
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text wrap + BBCodes
« Reply #1 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?

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: UILabel text wrap + BBCodes
« Reply #2 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.



The result is:



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:
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper

MigrantP

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: UILabel text wrap + BBCodes
« Reply #3 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel text wrap + BBCodes
« Reply #4 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.
« Last Edit: May 13, 2017, 01:09:50 PM by ArenMook »

soulburner

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: UILabel text wrap + BBCodes
« Reply #5 on: May 16, 2017, 06:36:21 AM »
Thanks!
Programmer at LazyBearGames.com
Making Punch Club and Graveyard Keeper