27 lines
695 B
C#
27 lines
695 B
C#
using System.Text;
|
|
using TMPro;
|
|
using Unity.Services.Leaderboards;
|
|
using UnityEngine;
|
|
|
|
public class LeaderBoardUI : MonoBehaviour
|
|
{
|
|
public TextMeshProUGUI scoretext;
|
|
private const string leaderBoardID = "helix_leaderboard";
|
|
|
|
public async void LoadLeaderBoard()
|
|
{
|
|
var score = await LeaderboardsService.Instance.GetScoresAsync(leaderBoardID, new GetScoresOptions { Limit = 10 });
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
int rank = 1;
|
|
|
|
foreach (var scoreEntry in score.Results)
|
|
{
|
|
sb.AppendLine($"{rank}.{scoreEntry.PlayerName}- {scoreEntry.Score}");
|
|
rank++;
|
|
}
|
|
|
|
scoretext.text = sb.ToString();
|
|
}
|
|
}
|