So, first sorry for my english. I'm from Brazil.
particularly I'm still learning C #, then. I follow a tutorial where to make a leaderboard, and in this leaderboard I want to show the player avatar url of everyone who is in the Ranking. But when i play in a debug, it always returns null.
I once managed to show the avatar of the current player who logged in. But not from the leaderboard.
void OnDisplayName(UpdateUserTitleDisplayNameResult result) { Debug.Log(result.DisplayName + "is your name"); } private void OnLoginFailure(PlayFabError error) { var registerRequest = new RegisterPlayFabUserRequest {Email = email, Password = password, Username = username}; PlayFabClientAPI.RegisterPlayFabUser(registerRequest, OnRegisterSuccess,OnRegisterFailure); errorRegister.gameObject.SetActive(true); } private void OnRegisterFailure (PlayFabError error) { Debug.Log(error.GenerateErrorReport()); errorRegister.gameObject.SetActive(true); } public void getUserEmail(string emailIn) { email = emailIn; } public void getUserPassword(string passwordIn) { password = passwordIn; } public void getUsername(string usernameIn) { username = usernameIn; } public void OnClickLogin () { var request = new LoginWithEmailAddressRequest {Email = email, Password = password}; PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure); } public int playerLevel; public int playerRank; public int playerMatch; public void GetPlayerStats () { PlayFabClientAPI.UpdatePlayerStatistics( new UpdatePlayerStatisticsRequest { // request.Statistics is a list, so multiple StatisticUpdate objects can be defined if required. Statistics = new List<StatisticUpdate> { new StatisticUpdate { StatisticName = "Player Level", Value = 6 }, new StatisticUpdate { StatisticName = "Player Rank", Value = 10 }, new StatisticUpdate { StatisticName = "Player Matchs", Value = 1 }, } }, result => { Debug.Log("User statistics updated"); }, error => { Debug.LogError(error.GenerateErrorReport()); }); } void GetStats() { PlayFabClientAPI.GetPlayerStatistics( new GetPlayerStatisticsRequest(), OnGetStatistics, error => Debug.LogError(error.GenerateErrorReport()) ); } void OnGetStatistics(GetPlayerStatisticsResult result) { Debug.Log("Received the following Statistics:"); foreach (var eachStat in result.Statistics) { Debug.Log("Statistic (" + eachStat.StatisticName + "): " + eachStat.Value); switch (eachStat.StatisticName) { case "Player Level": playerLevel = eachStat.Value; break; case "Player Rank": playerRank = eachStat.Value; break; case "Player Matchs": playerMatch = eachStat.Value; break; } } } // Build the request object and access the API public void StartCloudUpdatePlayerStats() { PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "UpdatePlayerStats", // Arbitrary function name (must exist in your uploaded cloud.js file) FunctionParameter = new { Level = playerLevel, Rank = playerRank, Match = playerMatch}, // The parameter provided to your function GeneratePlayStreamEvent = true, // Optional - Shows this event in PlayStream }, OnCloudUpdatePlayerStats, OnErrorShared); } // OnCloudHelloWorld defined in the next code block private void OnCloudUpdatePlayerStats(ExecuteCloudScriptResult result) { // CloudScript returns arbitrary results, so you have to evaluate them one step and one parameter at a time Debug.Log(PlayFab.PluginManager.GetPlugin<ISerializerPlugin>(PluginContract.PlayFab_Serializer)); JsonObject jsonResult = (JsonObject)result.FunctionResult; object messageValue; jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in CloudScript Debug.Log((string)messageValue); } private static void OnErrorShared(PlayFabError error) { Debug.Log(error.GenerateErrorReport()); } #region Leaderboards public void GetLeaderboard() { LeaderboardCanvas.SetActive(true); var requestLeaderboard = new GetLeaderboardRequest { StartPosition = 0, StatisticName = "Player Rank", MaxResultsCount = 50 }; PlayFabClientAPI.GetLeaderboard(requestLeaderboard, OnGetLeaderboard, OnGetLeaderboardError); } public GameObject leaderboardListPrefab; public Transform verticalLeaderboardList; public void OnGetLeaderboard(GetLeaderboardResult result) { //Debug.Log(result.Leaderboards[0].StatValue); foreach (PlayerLeaderboardEntry player in result.Leaderboard) { GameObject tempListing = Instantiate (leaderboardListPrefab,verticalLeaderboardList); PlayFabLeaderboardList Leaderboard = tempListing.GetComponent<PlayFabLeaderboardList>(); Leaderboard.PlayerName.text = player.DisplayName; Leaderboard.PlayerPDL.text = player.StatValue.ToString(); Debug.Log(player.Profile.AvatarUrl); } } /// <summary> /// </summary> public GameObject LeaderboardBackground; public GameObject LeaderboardCloseButton; public void OnCloseLeaderboard() { LeaderboardCanvas.SetActive(false); for (int i = verticalLeaderboardList.childCount -1; i>=0; i--) { Destroy(verticalLeaderboardList.GetChild(i).gameObject); } DontDestroyOnLoad(this.LeaderboardBackground); DontDestroyOnLoad(this.LeaderboardCloseButton); } public void OnGetLeaderboardError(PlayFabError error) { Debug.LogError(error.GenerateErrorReport()); } #endregion