I have this method, this method is called OnPointerClick from other script. It should remove item from slot and add new item to this slot. However it adds item to empty slot at first. But then, if i click another item, it removes item from slot, but not adding it.
public void RemoveUpgrade(ItemSO item)
{
UpgradePanelSlot slot = upgradePanelSlots[0];
UpgradePanelItem itemSlot = slot.GetComponentInChildren<UpgradePanelItem>();
if (itemSlot != null)
{
Destroy(itemSlot.gameObject);
Debug.Log("Good");
}
AddItemToUP(item);
}