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";
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?
asked Apr 22, 2010 at 10:03 AM
I found the solution.
I was previously retrieving the player's name in Awake() in Chat script. After putting the player name retrieval code in Update(), it is working.
answered Apr 23, 2010 at 08:49 AM
Would it not be better to assign the userName value from the text field when the player clicks Connect, as opposed to the whole time they are disconnected? I don't know, might need a little more detail still.
answered Apr 22, 2010 at 10:33 AM