I have a script that gets the username by PlayFab id and writes it to the variable TestName
It was taken (and slightly modified) from the original documentation: https://learn.microsoft.com/en-us/gaming/playfab/features/data/playerdata/getting-player-profiles
// Initially TestName not set void GetPlayerProfile(string playFabId) { PlayFabClientAPI.GetPlayerProfile( new GetPlayerProfileRequest() { PlayFabId = playFabId, ProfileConstraints = new PlayerProfileViewConstraints() { ShowDisplayName = true } }, result => TestName = result.PlayerProfile.DisplayName, error => Debug.LogError(error.GenerateErrorReport())); }
Next, I have a script that takes an array of leaderboard data and writes it to the Leaders
variable in a user-friendly format
void OnLeaderboardGet(GetLeaderboardResult result) { foreach (var item in result.Leaderboard) { GetPlayerProfile(item.PlayFabId); Debug.Log(TestName); Leaders += ((item.Position + 1) + ") " + TestName + ": " + item.StatValue + "\n"); } LeaderboardText.text = Leaders.ToString(); Debug.Log(Leaders); }
The problem occurs in the first function GetPlayerProfile(item.PlayFabId);
. The function receives a username with a delay and does not have time to overwrite the variable TestName
As a result I get this:
Are there solutions to download leaderboards with nicknames?
I have a script that gets the username by PlayFab id and writes it to the variable TestName
It was taken (and slightly modified) from the original documentation: https://learn.microsoft.com/en-us/gaming/playfab/features/data/playerdata/getting-player-profiles
// Initially TestName not set void GetPlayerProfile(string playFabId) { PlayFabClientAPI.GetPlayerProfile( new GetPlayerProfileRequest() { PlayFabId = playFabId, ProfileConstraints = new PlayerProfileViewConstraints() { ShowDisplayName = true } }, result => TestName = result.PlayerProfile.DisplayName, error => Debug.LogError(error.GenerateErrorReport())); }
Next, I have a script that takes an array of leaderboard data and writes it to the Leaders
variable in a user-friendly format
void OnLeaderboardGet(GetLeaderboardResult result) { foreach (var item in result.Leaderboard) { GetPlayerProfile(item.PlayFabId); Debug.Log(TestName); Leaders += ((item.Position + 1) + ") " + TestName + ": " + item.StatValue + "\n"); } LeaderboardText.text = Leaders.ToString(); Debug.Log(Leaders); }
The problem occurs in the first function GetPlayerProfile(item.PlayFabId);
. The function receives a username with a delay and does not have time to overwrite the variable TestName
As a result I get this:
Are there solutions to download leaderboards with nicknames?