public static bool AttemptSwap(ItemUIElement item1, ItemUIElement item2) { InventorySlotUI slot1 = item1.ItemInfo.CurrentSlot; InventorySlotUI slot2 = item2.ItemInfo.CurrentSlot; if (slot1.CanFitItem(item2.ItemInfo) && slot2.CanFitItem(item1.ItemInfo) && item1.ItemInfo.CanEnterInventory(slot2.m_container, slot2) && item2.ItemInfo.CanEnterInventory(slot1.m_container, slot1)) { Debug.Log("Moving item 1"); GameObject newSlot = Instantiate(m_instance.SlotPrefab, m_instance.transform); InventorySlotUI tempSlot = newSlot.GetComponent <InventorySlotUI>(); tempSlot.m_container = m_instance.m_Container; m_instance.MoveItemTo(item1, tempSlot); Debug.Log("Moving item 2"); m_instance.MoveItemTo(item2, slot1); m_instance.MoveItemTo(item1, slot2); Destroy(newSlot); return(true); } item1.ReturnPos(); item2.ReturnPos(); return(false); }