Hello, I am using Photon and PlayFab and have TextMeshPro text as the player name in the Photon player prefab, and in-game all the names and IDs are only showing mine. I know why this is happening, because it's getting the display name and ID sort of client-side for the currently authenticated user, but I'm wondering if there's a way to get it for each user then display each user's individual display name and ID. Here is my code:
public class PlayerNameScript : MonoBehaviour
{
public TextMeshPro playername;
private string displayName;
void Start()
{
GetDisplayName();
string playfabID = PlayFabSettings.staticPlayer.PlayFabId;
Debug.Log("player " + PhotonNetwork.LocalPlayer.ActorNumber);
playername.text = displayName + " | ID : " + playfabID;
}
// Update is called once per frame
void Update()
{
}
public void GetDisplayName()
{
PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest(), OnGetPlayerProfileSuccess, OnGetPlayerProfileError);
}
private void OnGetPlayerProfileSuccess(GetPlayerProfileResult result)
{
displayName = result.PlayerProfile.DisplayName;
Debug.Log("User Display Name: " + displayName);
}
private void OnGetPlayerProfileError(PlayFabError error)
{
Debug.LogError("GetPlayerProfile Error: " + error.ErrorMessage);
}
}