private void Start() { // Get the current prize index int index = PlayerPrefsFast.GetInt(this.RewardIndexKey, 0); // Get the last time a reward was given string lastDateString = PlayerPrefsFast.GetString(this.LastDateRewardKey, string.Empty); DateTime lastDate; bool parsed = DateTime.TryParse(lastDateString, out lastDate); if (parsed) { // Give reward after 1 day if (lastDate.AddDays(1) <= DateTime.Now) { // Give reward, and then set it to the next index index++; List <Transform> childRewards = this.RewardsGrid.GetChildList(); // Make sure we don't give more rewards that we hvae set up if (index <= childRewards.Count) { foreach (Transform child in childRewards) { DailyReward dailyReward = child.GetComponent <DailyReward>(); if (dailyReward != null) { dailyReward.SetCurrentReward(index); if (dailyReward.Day == index) { this.centerOnChildTarget = child.GetComponent <UICenterOnChild>(); } } } PlayerPrefsFast.SetInt(this.RewardIndexKey, index); PlayerPrefsFast.SetString(this.LastDateRewardKey, DateTime.Now.ToString()); PlayerPrefsFast.Flush(); this.RewardsGrid.enabled = true; this.RewardsGrid.repositionNow = true; this.refreshGrid = true; } else { this.gameObject.SetActive(false); } } else { this.gameObject.SetActive(false); } } else { // It's the first time, so set the date as now PlayerPrefsFast.SetString(this.LastDateRewardKey, DateTime.Now.ToString()); PlayerPrefsFast.Flush(); this.gameObject.SetActive(false); } }