public void Buy() { Item itemToBuy = database.GetItemByName(gameObject.transform.parent.name); inventory.GetComponent <Inventory>().AddItem(itemToBuy.ID); print(itemToBuy.name + " added to inventory"); }
void FindItems(string child, int num) { Item itemInSlot = database.GetItemByName(child); if (itemInSlot.name == shopSlot[num].name) { for (int i = 0; i < 3; i++) { if (i == 0) { shopSlot[num].transform.GetChild(i).GetComponent <Image>().sprite = itemInSlot.sprite; } else if (i == 1) { shopSlot[num].transform.GetChild(i).GetComponent <Text>().text = itemInSlot.name; } else { shopSlot[num].transform.GetChild(i).GetComponent <Text>().text = itemInSlot.price + " LN Stock: " + itemInSlot.stock; } } } }