public void addItemToSpecificSlot(int id, int slot) { if (items[slot].Id != -1) { Destroy(slots[slot].transform.GetChild(0).gameObject); } if (id == -1) { items[slot] = new Item(); return; } Item itemToAdd = database.GetItemByID(id); items[slot] = itemToAdd; if (slot == 33) { buyGoldText.text = "Gold: " + itemToAdd.Value * 2; } GameObject itemObj = Instantiate(item); ItemData itemdata = itemObj.GetComponent <ItemData>(); itemdata.item = itemToAdd; itemdata.amount = 1; itemdata.slot = slot; itemObj.transform.SetParent(slots[slot].transform); itemObj.GetComponent <Image>().sprite = itemToAdd.Sprite; itemObj.name = itemToAdd.Title; ItemData data = slots[slot].transform.GetChild(0).GetComponent <ItemData>(); if (slot < 8) { itemdata.EquipItem(); } if (id > -1) { data.transform.GetChild(0).GetComponent <Text>().text = ""; } data.transform.localScale = new Vector3(1, 1, 1); }