//Here we processing event when click on item public void OnPointerClick(PointerEventData eventData) { //Right click to drop if (eventData.clickCount > 1 && eventData.button == PointerEventData.InputButton.Right) { inventory.DropItem(this); return; } //Substract stack event if (eventData.clickCount > 1 && eventData.button == PointerEventData.InputButton.Left && item.stackable && item.stackSize > 1) { if (inventory.CheckFreeSpaceForAllSlots(item.width, item.height)) { inventory.SubstractStack(this); } } //Double click to swap item if it's not stackable if (eventData.clickCount > 1 && eventData.button == PointerEventData.InputButton.Left && !item.stackable) { print("Swap items"); if (equipmentPanel == null) { inventory.SwapEquipment(this, false); } } }
public void PickupWithRaycast() { RaycastHit hit = new RaycastHit(); if (Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out hit, raycastPickupDistance)) { if (itemNameTooltip) { itemNameTooltip.text = string.Empty; } if (hit.collider.CompareTag("Item") && hit.collider.GetComponent <Item>() != null) { var item = hit.collider.GetComponent <Item>(); if (itemNameTooltip) { if (item.stackable) { itemNameTooltip.text = string.Format("{0}x{1}", item.title, item.stackSize); } else { itemNameTooltip.text = string.Format("{0}", item.title); } } if (Input.GetKey(pickupKey) && inventory.CheckFreeSpaceForAllSlots(item.width, item.height)) { inventory.AddItem(hit.collider.GetComponent <Item>()); } } if (hit.collider.CompareTag("LootBox") && hit.collider.GetComponent <LootBox>() != null && !InventoryManager.showInventory) { if (itemNameTooltip) { itemNameTooltip.text = "Search"; } if (Input.GetKeyDown(pickupKey)) { inventory.SearchLootBox(hit.collider.GetComponent <LootBox>()); } } } else { if (itemNameTooltip != null && itemNameTooltip.text != string.Empty) { itemNameTooltip.text = string.Empty; } } }
//Here we processing event when click on item public void OnPointerClick(PointerEventData eventData) { //Right click to drop if (eventData.clickCount > 1 && eventData.button == PointerEventData.InputButton.Right) { inventory.DropItem(this); return; } //Substract stack event if (eventData.clickCount > 1 && eventData.button == PointerEventData.InputButton.Left && item.stackSize > 1) { if (inventory.CheckFreeSpaceForAllSlots(item.width, item.height)) { inventory.SubstractStack(this); } } }