Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: bloomk on May 18, 2017, 04:53:40 PM

Title: Label wrap problem
Post by: bloomk on May 18, 2017, 04:53:40 PM
In a recent version this started happening

It creates a new line when it should not..
Title: Re: Label wrap problem
Post by: ArenMook on May 19, 2017, 05:17:24 AM
Can you submit a simple repro project showing the issue so I can have a look? I don't see this problem on my end.
Title: Re: Label wrap problem
Post by: bloomk on May 19, 2017, 12:59:09 PM
I PM'd youth repo project..
Title: Re: Label wrap problem
Post by: ArenMook on May 25, 2017, 06:06:08 AM
Thanks! I imported your project, saw the issue then imported the latest NGUI and the issue was gone. So if the current Asset Store version still has the issue then it will be fixed in the next update.
Title: Re: Label wrap problem
Post by: bloomk on May 25, 2017, 01:23:03 PM
When is the next update? What version has the fix?
Title: Re: Label wrap problem
Post by: bloomk on May 26, 2017, 11:59:24 AM
?
Title: Re: Label wrap problem
Post by: Shifty Geezer on May 28, 2017, 05:20:00 AM
I am experiencing this problem. It happens with a text file obtained from an Amazon S3 storage bucket, where I'm placing my latest news. The same text loaded locally has no problems. If printed to console there are no line breaks. I've updated to the latest NGUI (3.11.3, downloaded today from direct link, not Asset Store).
Title: Re: Label wrap problem
Post by: Shifty Geezer on May 28, 2017, 06:08:10 AM
I've compared the source text (908 bytes), the downloaded text file from S3 (907 bytes), and saved the downloaded file to a text file (907 bytes) and they are identical.

Here's my code. The text is broken with or without typewriter effect being used.

  1.      private IEnumerator GetWWWNews() {
  2.                 if(!typewriter.enabled){
  3.                 yield return new WaitForSeconds(2);
  4.                         WWW w = new WWW("https://s3.eu-west-2.amazonaws.com/com.softwaregeezers.novawars/news.txt");
  5.                  yield return w;
  6.                  if (w.error != null){
  7.                                 Debug.Log("Error .. " +w.error);
  8.                                 typewriter.enabled = true;
  9.                                 newsLabel.text = offlineNews.text;
  10.                                 typewriter.ResetToBeginning();
  11.                                 scrollNews.ResetPosition();
  12.                  }else{
  13.                                 typewriter.enabled = true;
  14.                                 if(DEV_useOfflineNews){
  15.                                         newsLabel.text = offlineNews.text;
  16.                                 }else{
  17.                                         newsLabel.text = w.text;
  18.                                         print(w.text);
  19.                                         System.IO.File.WriteAllText("D:/_temp/newsOutput.txt", w.text);
  20.                                 }
  21.                                 typewriter.ResetToBeginning();
  22.                                 scrollNews.ResetPosition();
  23.                         }
  24.                 }
  25.         }
  26.  
Title: Re: Label wrap problem
Post by: Shifty Geezer on May 28, 2017, 06:23:28 AM
Repro case -
create a new NGUI project
add a UILabel
add a script that updates the label text using the above Unity WWW method
load in my text file from "https://s3.eu-west-2.amazonaws.com/com.softwaregeezers.novawars/news.txt"
Title: Re: Label wrap problem
Post by: bloomk on May 30, 2017, 03:04:30 PM
Can you please tell me when the update to fix this will be out... it has caused major issues in my game and we are all literally waiting for this update to fix these issues..
Title: Re: Label wrap problem
Post by: ArenMook on June 05, 2017, 03:47:58 AM
In the future, just reach out via email and request a zip of the latest NGUI version. It would only take me a minute, and you will have a fix right away. I was super busy over the past month -- and the last week even more so with the release of a public play test of my game, so an NGUI update on the Asset Store had to be delayed. Replying to a request for a ZIP though -- that would have been quick. I'll go ahead and put the NGUI update now.
Title: Re: Label wrap problem
Post by: Shifty Geezer on June 08, 2017, 04:32:51 PM
My problem is not fixed in the new version. A text document from the web gets chopped up in the wrong places as described above.
Title: Re: Label wrap problem
Post by: Shifty Geezer on June 08, 2017, 04:48:55 PM
If I strip out newlines and line-feeds (ignore characters with ASCII below 14), the wordwrapping works, but there are no paragraphs of course. Including either ASCII 10 or 13 breaks the word wrapping the same way.
Title: Re: Label wrap problem
Post by: Shifty Geezer on June 09, 2017, 04:23:30 AM
My current hack is to save the imported file to a local file, then load that file in and display the string. This works in the editor but not on devices.
Title: Re: Label wrap problem
Post by: ArenMook on June 10, 2017, 06:42:02 AM
I need a repro case, because everything works correctly on my end from both example projects I've received. Simply pasting code that references some external classes is not a repro case. :P
Title: Re: Label wrap problem
Post by: Shifty Geezer 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.
Title: Re: Label wrap problem
Post by: Shifty Geezer on June 13, 2017, 12:31:42 PM
Found email address in 'don't post projects with NGUI source' thread.
Title: Re: Label wrap problem
Post by: bloomk on June 14, 2017, 06:43:48 PM
My issue is still there as well...
Title: Re: Label wrap problem
Post by: bloomk on June 16, 2017, 04:56:48 PM
Any word on this?
Title: Re: Label wrap problem
Post by: Shifty Geezer 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?
Title: Re: Label wrap problem
Post by: ArenMook 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.
Title: Re: Label wrap problem
Post by: Shifty Geezer 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.