I have inventory and there is a frame. Moving it in a simple array.
if (Input.GetKeyDown(KeyCode.A)) { if(indexSlotForFrame - 1 >= 0) { indexSlotForFrame -= 1; leftRight--; } } if (Input.GetKeyDown(KeyCode.D)) { if(indexSlotForFrame + 1 <= slots.Count - 1) { indexSlotForFrame += 1; leftRight++; } } if (Input.GetKeyDown(KeyCode.W)) { if(indexSlotForFrame - frameAcross >= 0) { indexSlotForFrame -= frameAcross; } } if (Input.GetKeyDown(KeyCode.S)) { if(indexSlotForFrame + frameAcross <= slots.Count - 1) { indexSlotForFrame += frameAcross; } } and I just memorize the number and already transfer the slot
frame.transform.parent = slots[indexSlotForFrame].transform; frame.transform.position = slots[indexSlotForFrame].transform.position; But this system is not convenient, as can be seen from the code, because if I want to open a chest, where there is another array, I cannot connect them. Someone can throw off a video for me or write it myself, how to correctly make a system dragging a frame? (Inventory for the game, which will be on the console) In order that it was clear how I want to do, here is an example:
