Search Unity

  1. Click here to receive a gift with your purchase of Unity Pro or Unity Enterprise.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

ILeaderboard how to add scores

Discussion in 'Documentation' started by rezki, Jan 28, 2015.

  1. rezki

    rezki

    Joined:
    Oct 15, 2013
    Posts:
    53
    how to add scores for ILeaderboard. i haven't found any documentation about it



    using UnityEngine;
    using System.Collections;
    using UnityEngine.SocialPlatforms;

    public class LeaderBoard : MonoBehaviour {

    public ILeaderboard myLeaderboard = Social.CreateLeaderboard();
    public IScore score;

    void Start ()
    {
    Social.localUser.Authenticate(Authentication);
    myLeaderboard = Social.CreateLeaderboard();
    myLeaderboard.id = "TimeAttack";
    myLeaderboard.LoadScores(result => ShowLeaderBoard(result));
    }
    void Authentication (bool Succeded)
    {
    if(Succeded)
    {
    print("Success");
    }
    else
    {
    Debug.LogError("LEADERBOARD ERROR");
    }
    }
    void ShowLeaderBoard (bool result)
    {
    Debug.Log("Received " + myLeaderboard.scores.Length + " scores");
    foreach (IScore score in myLeaderboard.scores)
    {
    print(result.ToString());
    }
    }
    void AddToLeaderBoard()
    {

    }
    }
     
  2. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
  3. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
  4. rezki

    rezki

    Joined:
    Oct 15, 2013
    Posts:
    53
  5. rezki

    rezki

    Joined:
    Oct 15, 2013
    Posts:
    53
unityunity