Hi, I'm trying to make a leaderboard but I'm running into some issues when I try to get the players score and name for the leaderboard listings It always says that "DisplayName" nor "Username" exist in PlayerLeaderboardEntry but PlayFabId works. I want to grab the players username for the leaderboard entry but it just wont let me. Putting "LL.playerNameText.text = player.PlayFabID;" works fine but "LL.playerNameText.text = player.Username;" or "LL.playerNameText.text = player.DisplayName;" doesn't.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using PlayFab; using PlayFab.ClientModels; using PlayFab.ProfilesModels; public class LobbyLeaderboard : MonoBehaviour { public GameObject LBUI; public GameObject ListingPrefab; public Transform ListingContainer; private bool Show = false; // Start is called before the first frame update void Start() { LBUI.SetActive(false); } public void ShowMenu() { Show = !Show; if (Show) { GetLeaderboard (); LBUI.SetActive(true); } else { LBUI.SetActive(false); DestroyLeaderboard (); } } public void DestroyLeaderboard() { for(int i = ListingContainer.childCount - 1; i >= 0; i--) { Destroy (ListingContainer.GetChild (i).gameObject); } } public void GetLeaderboard() { var requestLeaderboard = new GetLeaderboardRequest { StartPosition = 0, StatisticName = "TotalGames", MaxResultsCount = 20 }; PlayFabClientAPI.GetLeaderboard (requestLeaderboard, OnGetLeaderboard, OnErrorLeaderboard); } public void OnGetLeaderboard(GetLeaderboardResult result) { //Debug.Log(result.Leaderboard[0].StatValue); foreach (PlayerLeaderboardEntry player in result.Leaderboard) { GameObject tempListing = Instantiate (ListingPrefab, ListingContainer); LeaderboardListing LL = tempListing.GetComponent<LeaderboardListing> (); LL.playerNameText.text = player.Username; LL.playerScoreText.text = player.StatValue.ToString(); Debug.Log(player.DisplayName + ": " + player.StatValue); } } public void OnErrorLeaderboard(PlayFabError error) { Debug.LogError (error.GenerateErrorReport ()); } }