public void mouseMovement() { //If mouse in the slot and left click and left shift and the slot is not locked or null if (isStay() && Input.GetMouseButtonDown(0) && Input.GetKey("left shift") && itemInSlot.id != "locked" && itemInSlot.id != "null") { //if the slot is on the main inventory and a box is open if (inventory.slotsLst.IndexOf(this.gameObject) >= 0 && inventory.getBoxInventory() != null) { //Place this slot to the first null object find inventory.oldMoveSlot(this.gameObject); BoxInventory box = inventory.getBoxInventory(); int index = -1; for (int i = 0; i < box.lstObj.Count; i++) { if (box.lstObj[i].id == "null" && index == -1) { index = i; inventory.newMoveSlot(box.lstSlots[i]); } } } //if the slot is on the box and a box is open else if (inventory.getBoxInventory() != null && inventory.getBoxInventory().lstSlots.IndexOf(this.gameObject) >= 0) { //Place this slot to the first null object find inventory.oldMoveSlot(this.gameObject); int index = -1; for (int i = 0; i < inventory.slotsLst.Count; i++) { if (inventory.slotsLst[i].GetComponent <Slot>().itemInSlot.id == "null" && index == -1) { index = i; inventory.newMoveSlot(inventory.slotsLst[i]); } } } else if (inventory.getBoxInventory() == null && inventory.slotsLst.IndexOf(this.gameObject) >= 0) { //Place this slot to the first null object find inventory.oldMoveSlot(this.gameObject); int index = -1; for (int i = 0; i < inventory.handSlotLst.Count; i++) { if (inventory.handSlotLst[i].GetComponent <Slot>().itemInSlot.id == "null" && index == -1) { index = i; inventory.newMoveSlot(inventory.handSlotLst[i]); } } } else if (inventory.getBoxInventory() == null && inventory.handSlotLst.IndexOf(this.gameObject) >= 0) { //Place this slot to the first null object find inventory.oldMoveSlot(this.gameObject); int index = -1; for (int i = 0; i < inventory.slotsLst.Count; i++) { if (inventory.slotsLst[i].GetComponent <Slot>().itemInSlot.id == "null" && index == -1) { index = i; inventory.newMoveSlot(inventory.slotsLst[i]); } } } needToDelete = true; deleteStats(); } else if (isStay() && Input.GetMouseButtonDown(0) && itemInSlot.id != "locked" && itemInSlot.id != "null") { slotFollow = Instantiate(objMouseFollow, this.transform.parent.parent.parent); slotFollow.transform.localScale = this.transform.parent.localScale; slotFollow.transform.GetChild(0).GetComponent <Image>().sprite = itemInSlot.getSprite(); diff = new Vector3(this.transform.position.x - Input.mousePosition.x, this.transform.position.y - Input.mousePosition.y, 0); inventory.oldMoveSlot(this.gameObject); } else if (isStay() && Input.GetMouseButtonDown(0) && (itemInSlot.id == "locked" || itemInSlot.id == "null")) { inventory.resetSaveSlot(); } if (Input.GetMouseButtonUp(0) && itemInSlot.id != "locked") { if (isStay()) { inventory.newMoveSlot(this.gameObject); } Destroy(slotFollow); slotFollow = null; } if (slotFollow != null) { float s = this.transform.parent.localScale.x; slotFollow.transform.position = new Vector3(diff.x + Input.mousePosition.x, diff.y + Input.mousePosition.y, 0); } }