Yesterday I ran this tutorial. http://www.youtube.com/watch?v=cIcCl4Ds9bI to make a login script. It uses JS.
I was learning the previous so I could modify this script which is in c#. http://wiki.unity3d.com/index.php/BOX1_-_gui_Login.cs_script
My goal was to be able to have options in the inspector to to position, size the gui input fields. The first tutorial (JS) does this, it has variables that give you positioning in size that can be tweaked in the inspector. I understood that very easily.
However, the second script which is the one I need is in c#, has none of the inspector options like the JS. I am trying to figure out how to add the function from that JS script to the c# login script. If that is possible.
If I could see some example code, I would be able to get a better starting point as it relates to what I need to happen.
This section below controls the input fields. Thanks.
// Show login fields if connected and reconnect button if disconnect
if (smartFox.IsConnected()) {
GUI.Label(new Rect(10, 116, 100, 100), "Username: ");
username = GUI.TextField(new Rect(100, 116, 200, 20), username, 25);
if ( GUI.Button(new Rect(100, 166, 100, 24), "Login") || (Event.current.type == EventType.keyDown Event.current.character == '\n')) {
smartFox.Login(zone, username, "");
}
} else {
if ( GUI.Button(new Rect(100, 166, 100, 24), "Reconnect") || (Event.current.type == EventType.keyDown Event.current.character == '\n')) {
Application.LoadLevel("sc_City");
}
}
// Draw box for status messages, if one is given
// Contains some logic to parse message of multiple lines if necessary
if (statusMessage.Length > 0)
{
int boxLength = 61; // define length of status box
int messageLength = statusMessage.Length; // get length of status message
string originalMessage = statusMessage; // copy message in to work string
string formattedMessage = ""; // define output message string
int i = 0;
while (i + boxLength < messageLength) // iterate and add newline until over length
{
formattedMessage = formattedMessage + originalMessage.Substring(i,boxLength) + "\n";
i = i + boxLength;
}
// add last piece of original message
formattedMessage = formattedMessage + originalMessage.Substring(i, boxLength - (i + boxLength - messageLength));
// draw status box with message
GUI.Box (new Rect (Screen.width - 420,10,400,48), formattedMessage);
}
}