| | |
| | | public GameObject itemUIPrefab; |
| | | public GameObject itemNameDescription; |
| | | public GameObject itemDescription; |
| | | public GameObject itemDeleteButton; |
| | | |
| | | public List<GameObject> itemUIs = new List<GameObject>(); |
| | | |
| | |
| | | if (itemNameDescription.GetComponent<ItemUIScript>()?.InventorySlot?.item?.itemName == inventorySlot.item.itemName) |
| | | { |
| | | itemDescription.SetActive(!itemNameDescription.activeSelf); |
| | | itemDeleteButton.SetActive(!itemNameDescription.activeSelf); |
| | | itemNameDescription.SetActive(!itemNameDescription.activeSelf); |
| | | } |
| | | else { |
| | | else |
| | | { |
| | | itemDescription.SetActive(true); |
| | | itemDeleteButton.SetActive(true); |
| | | itemNameDescription.SetActive(true); |
| | | } |
| | | itemNameDescription.GetComponent<ItemUIScript>().InventorySlot = inventorySlot; |
| | | itemDescription.GetComponent<ItemUIScript>().InventorySlot = inventorySlot; |
| | | } |
| | | public void OnItemDeleteClick() |
| | | { |
| | | InventorySlot inventorySlot = itemNameDescription.GetComponent<ItemUIScript>()?.InventorySlot; |
| | | if (inventorySlot?.item?.itemName != null) |
| | | { |
| | | inventory.RemoveItem(inventorySlot.item, inventorySlot.quantity); |
| | | itemNameDescription.SetActive(false); |
| | | itemDeleteButton.SetActive(false); |
| | | itemDescription.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | private void UpdateItemContentList() |
| | |
| | | |
| | | // Add click event listener only if the itemUI was just created |
| | | if (isCreated) |
| | | { |
| | | itemUI.GetComponent<Button>().onClick.AddListener(() => OnItemClick(itemUIScript.InventorySlot)); |
| | | } |
| | | else |
| | | { |
| | | // Update the itemUIScript of the itemNameDescription panel if the item is already selected |