using System; using System.Collections; using System.Collections.Generic; using System.Linq; public class LeaderboardWithDateController : LeaderboardController { public int DaysShow = 30; protected override void Start() { base.Start(); } protected override void UpdateLeaderboard() { _entries.ForEach(x => Destroy(x.gameObject)); _entries.Clear(); _entries = new List(); var sortedList = PlayerSetup.Instance.AllPlayers .Where(y => DateTime.Parse(y.DateTime) .AddDays(DaysShow) >= DateTime.Now) .OrderByDescending(x => x.Score) .ToList(); for (int i = 0; i < sortedList.Count; i++) { var newEntry = Instantiate(_leaderboardEntryPrefab, _content); _entries.Add(newEntry); newEntry.Init(sortedList[i], i); } } }