void ViewSlot <T>(int index, InventoryObject invObj, List <T> inventory) where T : InventoryObject { itemName.text = invObj.GetName(); itemDescription.text = invObj.GetDescription(); ((Text)drop.GetComponentInChildren(typeof(Text))).text = "Drop"; drop.onClick.AddListener(delegate() { ((Text)drop.GetComponentInChildren(typeof(Text))).text = "Confirm"; drop.onClick.AddListener(delegate() { inventory.RemoveAt(index); CancelViewSlot(); PopulateSlots(inventory); }); }); use.onClick.AddListener(delegate() { Use(invObj, delegate() { inventory.RemoveAt(index); Deactivate(); }); }); cancel.onClick.AddListener(CancelViewSlot); itemOptions.SetActive(true); }
void SetSlot <T>(int index, InventoryObject invObj, List <T> inventory) where T : InventoryObject { GameObject slot = slots[index]; slot.SetActive(invObj != null); Button slotButton = (Button)slot.GetComponent(typeof(Button)); if (invObj != null) { ((Text)slotButton.GetComponentInChildren(typeof(Text))).text = invObj.GetName(); slotButton.onClick.AddListener(delegate() { ViewSlot(index, invObj, inventory); }); } else { slotButton.onClick.RemoveAllListeners(); } }