Problems adding text to UI Text Component

I am building up a chat system for multiplayer, and am hitting a very strange wall that I can’t explain.

My setup for this is a text field to enter text, and then a UI text object.

For the first message, everything is added to the text object perfectly, however after the first message is sent, or after a script rebuild, no text is added.

I know for certain through debugging that the message is being sent, and received correctly. I also know that the function that is supposed to add the text is also receiving the message correctly.

What’s truly bizarre is if I test it offline, being I send the string from the text field straight to the text box, everything works perfectly.

I’ve also tried using the Concat method as well, same results (unsurprisingly). Full asset re-imports don’t help either. The code responsible for adding the string is pretty straight forward:

if (text.text.Length == 0)
	text.text += t;
else
	text.text += "

" + t;

“text” is a UI text.

Has anyone seen an issue like this before? Thanks!

Try to use this, the chat is the textbox, and inFi is the input field:

if (inFi.text != "")
            {
                chat.text += inFi.text;
                chat.text += "

";
inFi.text = “”;
}

Hope it works :smiley: