Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: sunriser on January 31, 2013, 11:22:05 AM

Title: TNManager.Playername change before joining channel
Post by: sunriser on January 31, 2013, 11:22:05 AM
First off, I recently purchased the TNET framework and, for the most part, this is a fantastic piece of work!

One thing I noticed is on the TNManager.playerName. I want to have the playerName updated AFTER a connect to a server but BEFORE joining a channel. This is so other players in the channel will see the player's updated name when the player joins a channel for chat.

In the TNET chat example, I added a line in the ExampleMenu.cs to change playerName BEFORE joining channel:

  1. if (GUI.Button(rect, sceneName, button))
  2.             {              
  3.                 // When a button is clicked, join the specified channel.
  4.                 // Whoever creates the channel also sets the scene that will be loaded by everyone who joins.
  5.                 // In this case, we are specifying the name of the scene we've just clicked on.
  6.                 TNManager.playerName = "Fred";
  7.                 TNManager.JoinChannel(i + 1, sceneName);
  8.                
  9.             }
  10.  

This gives me an error and prevents load of chat scene. Error is:

"ArgumentException: Getting control 0's position in a group with only 0 controls when doing Repaint
Aborting"

As it stands right now, I have to add the playername change AFTER the channel join, but other players in chat will see it as a "Guest" join message then rename to "Fred".

Is there any way to do playername changes before a channel join?

Thanks!
Title: Re: TNManager.Playername change before joining channel
Post by: ArenMook on February 01, 2013, 12:47:14 AM
The error you see comes from Unity's GUI. If you don't use Unity's GUI, you will not see it.
Title: Re: TNManager.Playername change before joining channel
Post by: sunriser on February 04, 2013, 02:40:27 PM
OK, I was just using your examplechat script to test a username change before channel join.

The problem still exists:

I used NGUI to create a chatbox and player list and when the TNManager.playerName is done before the TNManager.JoinChannel, the player doesn't connect to other players in the same channel (it just shows the Player with no others in channel)

Can you just try adding a TNManager.playerName before a TNManager.JoinChannel in your own example chat? If it's a problem on my end, I'll definitely troubleshoot my own issue.

Thank you!
Title: Re: TNManager.Playername change before joining channel
Post by: ArenMook on February 04, 2013, 07:28:08 PM
Player name has nothing to do with joining or not being able to join a channel. The player name is just a string -- a value that can be duplicated. Ie: you can have 10 players in the channel all named "Fred", and it's not an issue. You're saying you aren't able to join a channel if the name is set prior to joining a channel? That flat out doesn't make sense.

I'm currently in the process of adding a whole bunch of features to TNet such as UPnP and a better remote discovery / lobby server logic, so after that's done and everything compiles again, I will make sure that the name is set corectly.