Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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