37 lines
824 B
C#
37 lines
824 B
C#
using Photon.Pun;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class PlayerName : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text nameTag;
|
|
|
|
[SerializeField] private StringSharedField nick;
|
|
|
|
PhotonView photonView;
|
|
|
|
private void Awake()
|
|
{
|
|
photonView = GetComponent<PhotonView>();
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
if (!photonView.IsMine) return;
|
|
|
|
photonView.Owner.NickName = nick.Value;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (nameTag == null) return;
|
|
if (photonView == null) return;
|
|
if (photonView.Owner == null) return;
|
|
if (string.IsNullOrEmpty(photonView.Owner.NickName)) return;
|
|
nameTag.text = photonView.Owner.NickName;
|
|
}
|
|
}
|