question

daniel brunner avatar image
daniel brunner asked

Problem with GetPlayerStatistics

Hello; i have following Problem:

When i login the main menu scene appears with a textfield which shows the "SkillRating" of your player. This works perfectly fine until i switch to the game scene: the game (another scene) also has a textfield with the SkillRating of your player but this time the SkillRating always shows 0 and when i go back to the main menu the SkillRating is also set to 0. Here is my Code for the GetPlayerStatisticsRequest:

Can anyone explain me why the SkillRating changes after i swap the scene?

private void Awake()
 {
	 getSkillRating(); 
}

 public void getSkillRating() 
 { 
	 var request = new GetPlayerStatisticsRequest();
	 request.StatisticNames = new List<string>() { "SkillRating" };
	 PlayFabClientAPI.GetPlayerStatistics(request, OnGetSRSuccess, OnSetSRError);
 }

 private void OnSetSRError(PlayFabError obj)
 { 
	throw new NotImplementedException(); 
}

 private void OnGetSRSuccess(GetPlayerStatisticsResult obj)
 {
	 print("SR received");
	 foreach (var stat in obj.Statistics)
	 { 
	skillRating = stat.Value;
 }
	 skillRatingText.text = skillRating.ToString();
 }

Player Data
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

What's the result returned from PlayFabClientAPI.GetPlayerStatistics in the second scene? Would you please create a breakpoint around line 20 and watch it during debugging?

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.