Untitled

mail@pastecode.io avatar
unknown
csharp
3 years ago
417 B
5
Indexable
Never
public class NetworkPlayer : NetworkBehaviour
{
	[SyncVar]
	private string _playerName;

	public string PlayerName { get{ return _playerName; } }

	public override void OnStartServer()
	{
		var authMessage = (AuthData)connectionToClient.authenticationData;
		SetName(authMessage.PlayerName); //name is not null I checked
	}

	[Server]
	private void SetName(string name)
	{
		_playerName = name;
	}
}