You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SAE/Assets/Mirror/Examples/Chat/Scripts/Player.cs

30 lines
795 B

using System.Collections.Generic;
namespace Mirror.Examples.Chat
{
public class Player : NetworkBehaviour
{
public static readonly HashSet<string> playerNames = new HashSet<string>();
[SyncVar(hook = nameof(OnPlayerNameChanged))]
public string playerName;
// RuntimeInitializeOnLoadMethod -> fast playmode without domain reload
[UnityEngine.RuntimeInitializeOnLoadMethod]
static void ResetStatics()
{
playerNames.Clear();
}
void OnPlayerNameChanged(string _, string newName)
{
ChatUI.instance.localPlayerName = playerName;
}
public override void OnStartServer()
{
playerName = (string)connectionToClient.authenticationData;
}
}
}