Hi I am really struggling to see the default leaderboard UI in my game.
I couldnt quiet follow the documentation, here is what I did
1. I got the player to login with Facebook and inturn with Playfab, which works great
2. Then I am calling the following method every time the game ends to check if current score > Highscore -> UpdatePlayerStat (Which in turn updates the Leaderboard I hope)
publicvoidSetStats() {//Unity/C# varrequest=newUpdatePlayerStatisticsRequest { Statistics =newList<StatisticUpdate> { newStatisticUpdate{ StatisticName ="TopScores", Value =GameManager.instance.HighScore}, //request.Statisticsisalist,somultipleStatisticUpdateobjscanbedefinedifrequired. } }; PlayFabClientAPI.UpdatePlayerStatistics(request, result=> { Debug.Log("TopScoresset"); }, error=> { Debug.LogError(error.ErrorMessage); }); }
3. Then I added a script to a Leaderboard button in my game to show the leaderboard with the follwing script. I burrowed this code from the unicorn game and tbh I dont understand it at all
public void ShowLeaderboard_PlayFab() { PlayFabClientAPI.GetLeaderboard(new GetLeaderboardRequest{ StatisticName = "Top Scores", StartPosition = 0, MaxResultsCount = 10 }, (GetLeaderboardResult r) => { var leaderboard = r.Leaderboard; }, null); }
would be great if you could please help out here.
,Hi I am really struggling to see the default leaderboard UI in my game.
I couldnt quiet follow the documentation, here is what I did
1. I got the player to login with Facebook and inturn with Playfab, which works great
2. Then I am calling the following method every time the game ends to check if current score > Highscore -> UpdatePlayerStat (Which in turn updates the Leaderboard I hope)
publicvoidSetStats() {//Unity/C# varrequest=newUpdatePlayerStatisticsRequest { Statistics =newList<StatisticUpdate> { newStatisticUpdate{ StatisticName ="TopScores", Value =GameManager.instance.HighScore}, //request.Statisticsisalist,somultipleStatisticUpdateobjscanbedefinedifrequired. } }; PlayFabClientAPI.UpdatePlayerStatistics(request, result=> { Debug.Log("TopScoresset"); }, error=> { Debug.LogError(error.ErrorMessage); }); }
3. Then I added a script to a Leaderboard button in my game to show the leaderboard with the follwing script. I burrowed this code from the unicorn game and tbh I dont understand it at all
public void ShowLeaderboard_PlayFab() { PlayFabClientAPI.GetLeaderboard(new GetLeaderboardRequest{ StatisticName = "Top Scores", StartPosition = 0, MaxResultsCount = 10 }, (GetLeaderboardResult r) => { var leaderboard = r.Leaderboard; }, null); }
would be great if you could please help out here.