Author Topic: Label wrap problem  (Read 6847 times)

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: Label wrap problem
« Reply #15 on: June 13, 2017, 12:26:03 PM »
Where should I send a zip of a project? Although it's just a new project, NGUI 3.11.4, an NGUI label and a UnityUI Text. I run the script:
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class tester : MonoBehaviour {
  7.         public UIScrollView scrollNews;
  8.         public UILabel NGUI_newsLabel;
  9.         public TextAsset offlineNews;
  10.         public bool DEV_useOfflineNews;
  11.         public Text Unity_Text;
  12.  
  13.         // Use this for initialization
  14.         void Start () {
  15.                 StartCoroutine(GetWWWNews());                          
  16.         }
  17.  
  18.         private IEnumerator GetWWWNews() {
  19.                 WWW w = new WWW("https://s3.eu-west-2.amazonaws.com/com.softwaregeezers.novawars/newsBland.txt");
  20.                 yield return w;
  21.                 if (w.error != null){
  22.                         Debug.Log("Error .. " +w.error);
  23.                         NGUI_newsLabel.text = offlineNews.text;
  24.                 }else{
  25.                         if(DEV_useOfflineNews){
  26.                                 NGUI_newsLabel.text = offlineNews.text;
  27.                         }else{
  28.                                 NGUI_newsLabel.text = w.text;
  29.                                 print(w.text);
  30.                                 System.IO.File.WriteAllText("D:/_temp/newsOutput.txt", w.text);
  31.                         }
  32.                 }
  33.                 Unity_Text.text = NGUI_newsLabel.text;
  34.         }
  35. }
  36.  
I get the attached results. The Unity Text shows the text correctly wrapped, while the NGUI text breaks up the words.

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: Label wrap problem
« Reply #16 on: June 13, 2017, 12:31:42 PM »
Found email address in 'don't post projects with NGUI source' thread.

bloomk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
    • View Profile
Re: Label wrap problem
« Reply #17 on: June 14, 2017, 06:43:48 PM »
My issue is still there as well...

bloomk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 38
    • View Profile
Re: Label wrap problem
« Reply #18 on: June 16, 2017, 04:56:48 PM »
Any word on this?

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: Label wrap problem
« Reply #19 on: June 18, 2017, 07:51:16 AM »
Found email address in 'don't post projects with NGUI source' thread.
Did you get my email?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Label wrap problem
« Reply #20 on: June 18, 2017, 07:12:20 PM »
There were two problems with the repro case. First, the text contained characters outside the standard printable ASCII range: 65279, for example. This is what broke the word wrapping. Second, the text contained carriage-return breaks (\r) instead of line end (\n). NGUI works with \n, not \r, and if asian characters are encountered (which 65279 cetainly falls under), all word wrapping is turned off.

Sanitize your text after receiving it from your URL and before passing it to NGUI.

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: Label wrap problem
« Reply #21 on: June 19, 2017, 03:36:40 AM »
Yeah, Amazon S3 decided to muck it about. Thanks for that. Stripping the first char fixed the word-wrapping....
  1.         WWW w = new WWW("https://s3.eu-west-2.amazonaws.com/com.softwaregeezers.novawars/news.txt");
  2.         newsLabel.text = w.text.Substring(1,w.text.Length-1);
  3.