x


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.

more ▼

asked Aug 10 '11 at 10:16 PM

blacksuit_films gravatar image

blacksuit_films
1 7 7 8

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3688
x3460
x1363
x701
x419

asked: Aug 10 '11 at 10:16 PM

Seen: 686 times

Last Updated: Aug 10 '11 at 10:16 PM