Grey Zoned

Facebook SDK in Unity: Scores API

The even longer awaited part 3 of my Facebook SDK in Unity tutorial series is here!

In this tutorial I’ll guide you through how to:

  • How to get and set scores to and from Facebook
  • How to create a scrollable list with Unity’s new 4.6 UI system
  • How to populate that list with the scores from the user’s friends who have also played your game.



Let me know what you thought about the new chapter system. Should I use it in all my tutorials?

Comments and shares are appreciated! I hope you enjoy!

Glenn Mason

Tutorial by Glenn Mason

I've been interested in Game Development since I was about 11 years old when I started by making levels for Duke Nukem 3D, later moving on to creating Half-Life and Counter-Strike maps. Once I got into coding I went down the route of learning to make websites and web applications. Now I'm a professional Web Developer, running my own freelance business. However, my heart is still in Game Development. I started using Unity late in 2013. Since then I've released two Apps on the App stores that use Unity.

Tutorial Discussion

Home Forums Facebook SDK in Unity: Scores API

This topic contains 15 replies, has 15 voices, and was last updated by  Muhammad Farhan 2 years, 5 months ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
  • #572
    Glenn Mason
    Glenn Mason

    Please post any questions regarding bugs and technical support for this tutorial in this topic. This tutorial will soon be updated with a new one covering changes in Facebook SDK 7.3.0


    Patrick CJ Medina

    Waiting for the update! 🙂


    doha saizo

    awesome sir.
    i am wait sdk 7x and unity 5x for this tutorial.



    zack leonardo

    Trying to complete this tutorial but, I ran into a snag when trying to get the scores and adding them to the scoresDebug text and the debug.log. How would you access the “Text” from “Iresult” using unity 5.1 and facebook SDK 7.4.0. It won’t let me use result.Text as shown. Thanks for any insight.



    there is an issue while sending score. Its not working in Facebook plugin 7.4 can some one guide me its not giving publish permission and secondly how to track an app install, Like user send a app invite to a 2nd user to power up his lives now how can I know that the other user have downloaded the app and I should reward him. kindly explain me with example thanks


    iruo umusu

    Having problems deserializing score in sdk 7.4.0 get null Object Reference error, what should I do?


    Woo Ho

    Hi, guys I have a problem here. plz some one help me for scores the submit error (SetScore) the error is like this
    Any Idea About this? I search almost whole google website don’t even get the answer
    For Lastest Facebook SDK 7.3 and Unity 5.1

    Score submit result: {“error”:{“message”:”(#100) The parameter score is required”,”type”:”OAuthException”,”code”:100,”fbtrace_id”:”EHXhpJ50mX4″}}
    Facebook.FBHolder:<SetScore>m__21(IGraphResult) (at Assets/FacebookSDK/FBHolder.cs:146)
    Facebook.Unity.<Start>c__IteratorA:MoveNext() (at Assets/FacebookSDK/SDK/Scripts/Utils/AsyncRequestString.cs:133)


    Hi im watching your updated videos, but there isnt one for the leaderboard/scores video

    So i have been attempting to just work round the old code, i hit a wall wehn it came to the Scores CallBack bit

    scoresList = Util.DeserializeScores (result.Text);

    This line has changed since then, but cant figure out what the update is, and ive searched alot. i know result.Text is now, result.RawResult as it works, but for the Util im stuck..

    Any chance you know the update please?

    Thanks- D


    Michael Giles

    Hi. Do you know when you will be updating this tutorial to support sdk 7.4?

    this one is just not working.

    If you can upload an update soon or let me know. I am willing to pay for this type of support

    many thanks


    Hi Please Make A Leaderboard Tutorial! We need it


    shahbaz mancho

    Hi Sir
    Your tutorials are awesome , thank you for great tutorials.
    i am using unity 5.3 and SDK 7.8, all things are done with the help of your guidance except the score part. i want to show score of friends like you did in this tutorial , here is the code your code can you please set this for new version ?
    //// Score Code
    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()
    var scoreData = new Dictionary<string,string> ();
    scoreData [“score”] = Random.Range (10, 200).ToString ();
    FB.API (“/me/scores”, Facebook.HttpMethod.POST, delegate(FBResult result) {
    Debug.Log (“Score submit result: ” + result.Text);
    }, scoreData);

    Thank you


    kener cotrina

    Please update the video !!!


    todor valkov

    Hello. So I used this video to make a leaderboard and it works perfectly. The game is simple you play and u earn some points then if you click a button it loads the scene that lets log in facebook and lets you see your friends scores. But I added a button that lets you play again and the problem is that when the player clicks the button that loads the facebook scene both the NOTLOGGEDINUI and LOGGEDINUI are active. I tried few things that worked in the editor but when i tested it on my phone it didnt.



    todor valkov

    Also if someone can explain how to use the LogOut() function ill be grateful. Because just having FB.LogOut() doesnt work on my mobile device.


    faizan rasool

    hi sir you doing great i am getting this error Score submit result: {“error”:{“message”:”(#200) Requires extended permission: publish_actions”,”type”:”OAuthException”,”code”:200,”fbtrace_id”:”Hi9vzhr+Le6″}}
    UnityEngine.Debug:Log(Object) //login from admin account

    as tester working fine but score set on concosle no result update on screen

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.