LeaderboardUI

mail@pastecode.io avatar
unknown
csharp
24 days ago
749 B
0
Indexable
Never
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LeaderboardUI : MonoBehaviour
{
    public LeaderboardManager leaderboardManager;
    public Text leaderboardText;

    void Start()
    {
        DisplayLeaderboard();
    }

    public void DisplayLeaderboard()
    {
        List<ScoreEntry> leaderboard = leaderboardManager.LoadLeaderboard();
        leaderboardText.text = "";
        foreach (var entry in leaderboard)
        {
            leaderboardText.text += "Player: " + entry.playerName + " Score: " + entry.score + "\n";
        }
    }
    void ClearLeaderboard()
    {
        leaderboardManager.ClearLeaderboard();
        DisplayLeaderboard();  // Zaktualizuj wyświetlany leaderboard
    }
}
Leave a Comment