append more text in a chat box?

hey guys,
i’m making a combat log / chat window for my game.
im tying to figure out how to add more than one line or ‘append’ text to the next line in a gui.textarea or label… doesnt really matter what i use…

in this example:

GUI.Label (new Rect (0, 0, 765, 50), chatLogText);

if i have something new to add to the next line and i assign the value of that string to chatLogText it just replaces whats there…

is there an easy way to just
and start a new line without erasing whats already there and just add to it?


What you’re looking for is the += modifier.
If I start off with

string chatLogText = "Testing";

and I then add

chatLogText += "

An enemy has been slain";
chatLogText += "
Double kill!“;
chatLogText += "

The output from the program is:

An enemy has been slain
Double kill!

Be careful when adding lots of text to this though, after a while you may find you run out of space in your string. As quoted by the MSDN a string can contain “approximately 65,400 characters”.