Author Topic: UI Text List cuts off text when loading from text resource.  (Read 4934 times)

pstpetrov

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 5
    • View Profile
UI Text List cuts off text when loading from text resource.
« on: March 28, 2015, 09:42:22 PM »
I have an issue with Chat Area (UITextList). I have predefined text resources which are loaded based on which game object (GO) the user taps on. These are paragraphs usually 10-20 lines of text. It loads properly in my production version (released in April 2014, not sure which NGUI version).

Now with NGUI 3.8.0 only the text which can be shown on the screen (without moving the scrollbar) is loaded. It looks like the script cuts off the rest and when you scroll down it is empty. You can see in the screenshot how the paragraph is cut off at: "the pressure is still the". There is more text after that which is not loaded.

Here is my code:

TextAsset txt = (TextAsset)Resources.Load("TextAssets/Centers/" + GO.name.ToString(), typeof(TextAsset));
            
string content = txt.text;

TextList.Clear();
TextList.Add(content);
//I also tried this as a public member: TextList.Rebuild();, no success

What am I missing

Thanks,
Petar

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Text List cuts off text when loading from text resource.
« Reply #1 on: March 30, 2015, 01:53:52 AM »
I can't think of anything off the top of my head. Have you tried Debug.Logging the lines as they get added?

pstpetrov

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UI Text List cuts off text when loading from text resource.
« Reply #2 on: March 30, 2015, 06:49:28 AM »
Yes I have tried that. The correct text is added, it is not cut off before that step.

I tried the same in the sample chat scene. The text is still cut off but when I resize the chat area using the bottom right gadget the text appears. The scroller doesn't update though.

Steps:
1. Add a paragraph to the chat area programatically.
2. Text is cut off
3. Resize Chat Area using the bottom right gadget.
4. Text appears but scroller doesn't work. Scroller works only when I add a second paragraph.
« Last Edit: March 30, 2015, 09:15:06 AM by pstpetrov »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Text List cuts off text when loading from text resource.
« Reply #3 on: April 01, 2015, 11:11:14 PM »
Ok so how would I reproduce this in the sample scene? The chat window's contents are already populated via code when the scene starts up. Nothing gets cut off. Typing text in the input field and hitting Enter also adds it to the text list programmatically. Again everything works as expected.

pstpetrov

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UI Text List cuts off text when loading from text resource.
« Reply #4 on: April 02, 2015, 04:50:15 PM »
Here is how to replicate it:

1. Create new project with NGUI and open the Chat Area scene (Example 12).
2. Create the Resources folder and drop the attached .txt file in it. This will be a text resource.
3. Modify the ChatInput.cs script. Replace everything under OnSubmit() with:

TextAsset txt = (TextAsset)Resources.Load("C8 - root - undefined", typeof(TextAsset));
textList.Add(txt.text);

4. When you run the project and hit Enter on the Input Edit Field you will see how the text is cut off. It ends with "is coming fr", see attached screenshot. When you scroll up and down it doesn't show as well. The only thing you can do is use the resize thing at the bottom right and then it works.
« Last Edit: April 02, 2015, 05:21:04 PM by pstpetrov »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Text List cuts off text when loading from text resource.
« Reply #5 on: April 04, 2015, 04:05:20 AM »
Got it, thanks.

Open up UITextList.cs, line 259 and add a line to set regionHeight in addition to rectHeight:
  1.                         NGUIText.rectHeight = 1000000;
  2.                         NGUIText.regionHeight = 1000000; // <-- this