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 any solutions for fast loading leaderboards?


I don't know if this is the best way. The reason that the necessary data is not coming out seems to be because the leaderboard was not properly received.
If you do as above, the appropriate leaderboard data will be put in a variable called '_leaderBoard'. If there is another way to asynchronously wait for a value to come in, you can use that method.
Hope this helps you. :)