- Home /
More like a bulletin than chat box
Okay, so far I have a script for a GUI message system here:
enter code here
var stringToEdit: String = "What's The News?"; var customSkin: GUISkin; var newMessage = false; var maxMessage = 10; var messagesTyped: String[]; var messageSpacing: float = 10; var maxChar : int = 30; var scrollPosition : Vector2 = Vector2.zero; var messageAlert : String = "New Message From "; var nameField: String = "Name";
private var msgCounter: int;
function Start() { maxMessage--; messagesTyped = new String[maxMessage]; }
function OnGUI() { GUI.skin = customSkin;
stringToEdit = GUI.TextField(Rect(270, 100, 450, 80), stringToEdit, maxChar);
nameField = GUI.TextField(Rect(80, 100, 180, 30), nameField, maxChar);
if (GUI.Button(Rect(730, 100, 60, 30), "Submit"))
{
SubmitMsg( messageAlert + nameField + ": " + stringToEdit);
}
var x: float = 270;
var y: float = 180;
for (var i: int;
i < messagesTyped.length;
i++)
{
y += messageSpacing;
//print("Here");
GUI.Label(Rect(x, y, 500, 60), messagesTyped[i]);
}
} function SubmitMsg(submittedMsg: String) { if (msgCounter == maxMessage) { msgCounter = 0; } messagesTyped[msgCounter] = submittedMsg; print(messagesTyped[0]); msgCounter++; }
So these are the basic functions I want the script to perform but now I need to find a way for the messages to remain for other people to see even after closing and reopening the game. I wanted to find out if a good way to do this would be putting the string text into an array and using arrayprefs2 to save and recall the list when people enter the page and post new messages.
I kinda need a bit of handholding here. At first I thought I'd got the database route (or www class) but I'm having trouble finding any tutorials on how to get the desired outcome for this script using any route.
All help is well appreciated.