- Home /
List of Text Lines
I want to have a conversation window where the player and an NPC add text of various length, eg:
Hero: Are you a guard?
Guy: No.
Hero: Tell me about dragons.
Guy: This is a long reply. [Several lines of details]
What is the best practice for keeping the last N lines' worth of text in a window and deleting those that are the oldest? I've tried treating lines as child objects of a Panel, but since their length varies greatly, I get problems with text overflow because I can't just say "if lines.count > 5 delete lines[0]".
I'm thinking of something that looks very much like the conversation system in "Morrowind": Example screenshot. Doesn't necessarily need a ScrollRect if I'm just keeping the latest N lines, but it must be actual lines of text rather than strings of greatly varying length. I am also fine with not having distinct "line" objects, and just keeping the last ~400 vertical pixels' worth of text, if that's a better option.
(If someone asks if you're a guard, you say yes!)
You could put the lines in a list or array, then display list[i] through list[i+x] where i represents how far down you've scrolled and x is the height of the display box
Calculating something about the height of the display box might be doable, if I knew the height of every individual string being added, but I don't. Some strings will be "Yes" and some will be four-line dissertations on dragon scales. How can I say "I want to keep the last 10 horizontal lines' worth of text at most"?
Your answer
Follow this Question
Related Questions
Why is text ui cant be static ? 0 Answers
How to make disappear a GUI text after an amount of time? 5 Answers
Text does not wrap properly 1 Answer
Custom text UI 1 Answer
Pop up text from Floating text positioner interface c# 0 Answers