private void CreateLinks() { Date currentDate = pastSites[0].dateVisited; //Most recent CreateHeader(currentDate); for (int i = 0; i < pastSites.Count; i++) { if (CompareDates(pastSites[i].dateVisited, currentDate) != 0) { //Make some blank space TMPro.TextMeshProUGUI blank = Instantiate(textPrefab) as TMPro.TextMeshProUGUI; blank.transform.SetParent(historySite.transform, false); blank.text = " "; currentDate = pastSites[i].dateVisited; CreateHeader(currentDate); } GameObject link = Instantiate(linkPrefab); link.transform.SetParent(historySite.transform); int tmp = i; //Otherwise, i will be out of range inside the listener link.GetComponent <Button>().onClick.AddListener(() => { searchBar.text = pastSites[tmp].url; browser.CheckURL(pastSites[tmp].url); }); TMPro.TextMeshProUGUI linkText = link.GetComponent <TMPro.TextMeshProUGUI>(); linkText.fontSize = linkSize; linkText.text = pastSites[i].displayedText; link.transform.localScale = Vector3.one; } LayoutRebuilder.ForceRebuildLayoutImmediate(verticalLayout.GetComponent <RectTransform>()); }