I am adding the chat functionality in my Unity game. I am asking the username along with the IP address and Port number.
static var userName : String = "Player";
function OnGUI ()
{
if (Network.peerType == NetworkPeerType.Disconnected){
userName = GUILayout.TextField(userName);
....
}else{...}
Now when I click on Connect to Server, it takes the default value of username instead of the current value written in the TextField.
And when I disconnect and then reconnect it will take the previous value written in the TextField. So as a result it always takes the previous value that was written in the TextField instead of the current one.
Can anyone please point out my mistake?