Dialogue & GUI Text String

Hi all! I’ve been trying to create a simple, easy dialogue system using only one GUIText. So far, this is all I have, but it only displays the last string element typed. Is there a way to have multiple lines, or a line for each element string? Thanks for the help in advance! :smiley:

var dialogue = false;

var Text : GUIText;

var dialogLines : String; 

 

function Start(){

if(dialogue){

    for(var item : String in dialogLines){

        Text.text = item;

    }

}

What I’d do is create a list of lines, then cycle through them. In pseudocode:

lines as (string, 10)

def AddLine(text):
    for i in range(1,9):
        lines[i-1] = lines

lines[-1] = text
This way you’re replacing the contents of lines[0] with the contents of lines[1], which deletes the old lines[0], then moving lines[2] up to 1, and so on, and finally putting the new text into the last slot, #9. If you’re then wanting to put all of that text into a single paragraph you could do a string join operation, something like " ".join(lines).
By the way, my limited understanding is that GUIText does not have built-in line wrapping, while the GUI.Box function does (if the GUI style has a checkbox marked for that), so you might want to use GUI.Box instead. I’d like to get a system in place where I can easily say “pop up a box that has this auto-word-wrapped text, then let me know when the user’s hit Enter or something to clear it”. Please provide a link if you end up producing a good system you’d like to share!