using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class LeaderboardController : MonoBehaviour { [SerializeField] private RectTransform _content; [SerializeField] private LeaderboardEntry _leaderboardEntryPrefab; [SerializeField] private PlayerInfo _playerInfo; private void Start() { UpdateLeaderboard(); } private void UpdateLeaderboard() { var sortedList = _playerInfo.Players.OrderByDescending(x => x.Score).ToList(); for (int i = 0; i < sortedList.Count; i++) { var newEntry = Instantiate(_leaderboardEntryPrefab, _content); newEntry.Init(sortedList[i], i); } } }