Hi, I have a strange bug.
If a drop the first Item from the inventory it will drops all items.
And for example I have 6 items in the inventory and I drop the fourth, then it drops the first and second.
The script belows is on the InventorySlot prefab attached.
public class ChangeSlotUI : MonoBehaviour
{
private InventorySlotUI inventorySlotUI;
private UserInput userInput;
private float canInput = -1f;
private float generalInputRate = 2f;
private void Awake()
{
userInput = new UserInput();
//userInput.Inventory.Drop.performed += drop => DropItem();
//userInput.Inventory.Equip.performed += equip => EquipItem();
}
private void OnEnable()
{
userInput.Enable();
}
private void OnDisable()
{
userInput.Disable();
}
private void Start()
{
inventorySlotUI = GetComponent<InventorySlotUI>();
}
private void Update()
{
DropItem();
EquipItem();
}
private void DropItem()
{
//float drop = userInput.Inventory.Drop.ReadValue<float>();
if (userInput.Inventory.Drop.triggered && inventorySlotUI.GetItem() != null && Time.time > canInput)
{
canInput = Time.time + generalInputRate;
Debug.Log("You have droped the item");
var target = GameObject.FindGameObjectWithTag("InventoryCanvas").GetComponent<InventoryDropTarget>();
target.AddItems(inventorySlotUI.GetItem(), inventorySlotUI.GetNumber());
inventorySlotUI.RemoveItems(inventorySlotUI.GetNumber());
}
}
private void EquipItem()
{
float equip = userInput.Inventory.Equip.ReadValue<float>();
if (equip == 1 && inventorySlotUI.GetItem() != null && Time.time > canInput)
{
canInput = Time.time + generalInputRate;
Debug.Log("The Item is equiped");
}
}
}