using UnityEngine;
using System.Collections;
public class PlayerName : MonoBehaviour {
void OnGUI()
{
Vector3 offset = new Vector3(0, 3, 0); // height above the target position
Vector3 point = Camera.main.WorldToScreenPoint(transform.position + offset);
point.y = Screen.height - point.y;
GUI.Label(new Rect(point.x - 35, point.y - 20, 200, 20), PhotonNetwork.playerName);
}
}
This script is attacked to the instanced player object which has a photonview attached. The script will display names above all connected users, however the name will be that of player belonging to the local client. i.e. if you connect with the player name “player1”, all players will display “player1” above their heads. Here is a image to illustrate the issue.