public void PopulateInventory() { foreach (Transform child in parentLocation.transform) { GameObject.Destroy(child.gameObject); } if (inventory.GetInvevtory.Count > 0) { if (inventory.GetInvevtory.Count > 3) { inventory.GetInvevtory.Sort(delegate(ItemScriptable x, ItemScriptable y) { return(y.rarity.CompareTo(x.rarity)); }); } for (int i = 0; i < inventory.GetInvevtory.Count; i++) { GameObject temp = Instantiate(iconPrefab, parentLocation.transform); temp.GetComponent <SetItemIcon>().UpdateIconUI(inventory.GetInvevtory[i]); temp.GetComponent <CompareAndDisplayDetails>().SetItemAndEquipment(inventory.GetInvevtory[i], equipmentPanel.GetHero(), equipmentPanel); //temp.AddComponent<DraggableComponent>(); //Destroy(temp.GetComponent<Button>()); //Destroy(temp.GetComponent<EventTrigger>()); } inventoryCount.text = inventory.GetInvevtory.Count + "/200"; } goldValue.text = inventory.Gold.value.ToString(); }