private void AddItem() { //Computer int id = 0; foreach (Computer item in ComputerList.GetList()) { //Set attributes GameObject newItem = Instantiate(itemFrame, computerGrid.transform); newItem.GetComponent <IDScript>().id = id++; newItem.tag = "Computer"; //Set displays newItem.transform.Find("Model").GetComponent <Text>().text = item.GetModel(); newItem.transform.Find("Image").GetComponent <Image>().sprite = item.GetImage(); newItem.transform.Find("Value").GetComponent <Text>().text = item.GetSpeed().ToString() + "\n" + item.GetWatt().ToString(); newItem.transform.Find("Price").GetComponent <Text>().text = "$" + item.GetPrice(); //Set button events Button itemButton = newItem.GetComponent <Button>(); itemButton.onClick.AddListener(() => BuyItem(newItem)); } //Graphic card id = 0; foreach (GraphicCard item in GraphicCardList.GetList()) { GameObject newItem = Instantiate(itemFrame, graphicCardGrid.transform); newItem.GetComponent <IDScript>().id = id++; newItem.tag = "GraphicCard"; newItem.transform.Find("Model").GetComponent <Text>().text = item.GetModel(); newItem.transform.Find("Image").GetComponent <Image>().sprite = item.GetImage(); newItem.transform.Find("Value").GetComponent <Text>().text = item.GetSpeed().ToString() + "\n" + item.GetWatt().ToString(); newItem.transform.Find("Price").GetComponent <Text>().text = "$" + item.GetPrice(); Button itemButton = newItem.GetComponent <Button>(); itemButton.onClick.AddListener(() => BuyItem(newItem)); } //Asic id = 0; foreach (Asic item in AsicList.GetList()) { GameObject newItem = Instantiate(itemFrame, asicGrid.transform); newItem.GetComponent <IDScript>().id = id++; newItem.tag = "Asic"; newItem.transform.Find("Model").GetComponent <Text>().text = item.GetModel(); newItem.transform.Find("Image").GetComponent <Image>().sprite = item.GetImage(); newItem.transform.Find("Value").GetComponent <Text>().text = item.GetSpeed().ToString() + "\n" + item.GetWatt().ToString(); newItem.transform.Find("Price").GetComponent <Text>().text = "$" + item.GetPrice(); Button itemButton = newItem.GetComponent <Button>(); itemButton.onClick.AddListener(() => BuyItem(newItem)); } }