Quantcast
Channel: Questions in topic: "slot"
Viewing all articles
Browse latest Browse all 109

Inventory Dragging Item Problem

$
0
0
Hello, I am having quite an issue with my inventory system right now. I want to drag items and I want to detect if the selected item was dragged onto an actual slot or not. I created a really basic code for that which definitely needs optimization, but it should work. Well, it doesn't, and after trying to fix that weird error for about an hour, I give up. So, hopefully some of you can help me, I have no clue why the code is not working. I logged everything, but the correct result is not given. I am looping through all the slots in the inventory. This code is used for one individual slot. Also: If I remove the else statement, everything works fine. So the else statement is somehow triggered instead of the actual if statement. if (slotRect.Contains(currentEvent.mousePosition)) { if (isDragging && currentEvent.type == EventType.mouseUp) { Debug.Log ("In Slot."); // never reached but the contains method does work database.InventoryItems[dragIndex] = database.InventoryItems[count]; database.InventoryItems[count] = draggedItem; draggedItem = null; isDragging = false; return; } } else { if (isDragging && currentEvent.type == EventType.mouseUp) { Debug.Log ("Not in Slot."); database.InventoryItems[dragIndex] = draggedItem; draggedItem = null; isDragging = false; return; } }

Viewing all articles
Browse latest Browse all 109

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>