我开发了一个简单的游戏,我使用 Facebook SDK 统一制作排名部分,TestUsers 一切正常,但在我发布后,排名不适用于普通用户。
也许 FB.login 有问题?
FB.Login("email, publish_actions", AuthCallback);
或者我的分数保存代码?我不这么认为,b/c 与测试用户一起使用
// All Scores API related Things
public void QueryScores()
{
FB.API ("/app/scores?fields=score,user.limit(30)", Facebook.HttpMethod.GET, ScoresCallback);
}
private void ScoresCallback(FBResult result)
{
Debug.Log ("Scores callback: " + result.Text);
scoresList = Util.DeserializeScores (result.Text);
foreach (Transform child in ScoreScrollList.transform)
{
GameObject.Destroy (child.gameObject);
}
foreach (object score in scoresList)
{
var entry = (Dictionary<string,object>) score;
var user = (Dictionary<string,object>) entry["user"];
GameObject ScorePanel;
ScorePanel = Instantiate (ScoreEntryPanel) as GameObject;
ScorePanel.transform.parent = ScoreScrollList.transform;
Transform ThisScoreName = ScorePanel.transform.Find ("FriendName");
Transform ThisScoreScore = ScorePanel.transform.Find ("FriendScore");
Text ScoreName = ThisScoreName.GetComponent<Text>();
Text ScoreScore = ThisScoreScore.GetComponent<Text>();
ScoreName.text = user["name"].ToString();
ScoreScore.text = entry["score"].ToString();
Transform TheUserAvatar = ScorePanel.transform.Find ("FriendAvatar");
Image UserAvatar = TheUserAvatar.GetComponent<Image>();
FB.API (Util.GetPictureURL(user["id"].ToString (), 128,128), Facebook.HttpMethod.GET, delegate(FBResult pictureResult){
if(pictureResult.Error != null) // if there was an error
{
Debug.Log (pictureResult.Error);
}
else // if everything was fine
{
UserAvatar.sprite = Sprite.Create (pictureResult.Texture, new Rect(0,0,128,128), new Vector2(0,0));
}
});
}
}
public void SetScore()
{
string highScore = PlayerPrefs.GetInt("recorde").ToString();
var scoreData = new Dictionary<string,string> ();
scoreData ["score"] = highScore;
FB.API ("/me/scores", Facebook.HttpMethod.POST, delegate(FBResult result) {
Debug.Log ("Score submit result: " + result.Text);
if(result.Text == "{\"success\":true}"){
QueryScores();
}
}, scoreData);
}