- Home /
Building a Message Board
Hi There
I'm trying to write a script to build an online message box and its proving difficult. So far I have a text field for writing the messages, a 'submit' button which once pressed creates a GUI.Label below with the message text on it.
There are a couple of problems though and though i've searched around for answers none of the solutions have worked so far.
Here's where i'm at:
Code:
var stringToEdit : String = "What's The News?"; var customSkin : GUISkin; var newMessage = false;
function OnGUI () { GUI.skin = customSkin;
stringToEdit = GUI.TextField (Rect (220, 130, 500, 60), stringToEdit, 25);
if (GUI.RepeatButton(Rect(730,130,60,30),"Submit"))
newMessage = true;
if (newMessage){
GUI.Label (Rect (220, 340,500,60), "New Message: " + stringToEdit);
}
}
This is the best I can do so far but because if the functions I'm after this code isn't really near what i'm after. The first problem is that once I click the submit button and a GUI.Label appears below the text on it continues to change with the text field making it impossible to write a new message.
The other problem is creating multiple messages, It may work with one but is there a way to create an new GUI every time the submit button is pressed?
Could really do with a hand, I hope you guys can give me a leg up.
Your answer
![](https://koobas.hobune.stream/wayback/20220612173753im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
CHAT Multiplayer Problem 1 Answer
in-game chat woe... 3 Answers
Textfield doesnt work; it doesnt apply string 0 Answers
Can you have a scrollview inside a textfield? 0 Answers
Text fields where text will scale along with resolution. 1 Answer