Author Topic: UI text list paragraph  (Read 17166 times)

skatola

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 31
    • View Profile
UI text list paragraph
« on: August 07, 2015, 10:11:11 PM »
Hi, i'm trying to use ui text list in a inusual way and i need to write in textlist.add letter one by one with this script:

  1.         IEnumerator writing()
  2.                 {
  3.                         foreach (char letter in mytext.ToCharArray())
  4.                         {
  5.                                 textList.Add(letter.ToString());
  6.                                 yield return new WaitForSeconds (0.2f);
  7.                         }

My problem is: there is a way to avoid the paragraph after any letter inserted?
i just wanna see on the screen "hello world" and not
h
e
l
l
o
...

i'm trying to use this script for a nonchat use cause i like his behaviour to move the text field area with the text added.
i'm a novice in coding and maybe there is a simpler way to do that, can u help me? thanks : )

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI text list paragraph
« Reply #1 on: August 08, 2015, 11:37:44 PM »
UITextList is limited to adding by lines. If you want to append to an existing label, use only one label, not UITextList. Also look at the Typewriter script, it does just that.

skatola

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: UI text list paragraph
« Reply #2 on: August 09, 2015, 09:25:03 PM »
UITextList is limited to adding by lines. If you want to append to an existing label, use only one label, not UITextList. Also look at the Typewriter script, it does just that.

tried your typewriter script, it's so cool!
just a problem, i tried to assign a function on the ispector to typewriter onfinished event for do something when the script finish to write, but nothing happen, tried to debug.log that function and the event trigger only when i stop the scene, any idea why?

EDIT: if i use my_typewritereffect.Finish() function onfinished event works fine, but without that when it finish with typing nothing happen : (
« Last Edit: August 09, 2015, 09:34:23 PM by skatola »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI text list paragraph
« Reply #3 on: August 14, 2015, 08:12:46 AM »
I think it's due to a bug I fixed in the Pro version a while back.

Find line 213 in TypeWriterEffect. If it's just one line like this:
  1. mLabel.text = mFullText;
change it to be:
  1.                         mLabel.text = mFullText;
  2.                         current = this;
  3.                         EventDelegate.Execute(onFinished);
  4.                         current = null;
  5.                         mActive = false;

skatola

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: UI text list paragraph
« Reply #4 on: August 14, 2015, 01:20:54 PM »
Chenged it, now it's perfect, thank you!

skatola

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: UI text list paragraph
« Reply #5 on: August 14, 2015, 08:40:00 PM »
sry if i bother u again, hope this is the last one, be patient with me :\
i'm trying to add text to the label with typewritereffect attached but the script work only the first time.
i can't add some text to that label in the future (after onfinished called) with the same behaviour?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI text list paragraph
« Reply #6 on: August 15, 2015, 11:10:03 PM »
You need to reset the typewriter effect if you change the label's text.

skatola

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 31
    • View Profile
Re: UI text list paragraph
« Reply #7 on: August 16, 2015, 09:04:39 AM »
did u mean ResetToBeginning () function?
if i use it i lose my previous text, there is a way to reset typewriter without losing previous text? i just want to add text to the string

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI text list paragraph
« Reply #8 on: August 18, 2015, 04:26:18 PM »
Once the typewriter effect begins, it caches the text it started with because it then has to change the content of the label every time it updates. So in short, no, you can't append text to it while it's active. If you need that kind of functionality you will need to write your own code instead of using the typewriter effect.