31 lines
780 B
C#
31 lines
780 B
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Mirror.Examples.Chat
|
|
{
|
|
public class Player : NetworkBehaviour
|
|
{
|
|
internal static readonly HashSet<string> playerNames = new HashSet<string>();
|
|
|
|
[SerializeField, SyncVar]
|
|
internal string playerName;
|
|
|
|
// RuntimeInitializeOnLoadMethod -> fast playmode without domain reload
|
|
[UnityEngine.RuntimeInitializeOnLoadMethod]
|
|
static void ResetStatics()
|
|
{
|
|
playerNames.Clear();
|
|
}
|
|
|
|
public override void OnStartServer()
|
|
{
|
|
playerName = (string)connectionToClient.authenticationData;
|
|
}
|
|
|
|
public override void OnStartLocalPlayer()
|
|
{
|
|
ChatUI.localPlayerName = playerName;
|
|
}
|
|
}
|
|
}
|