private void Update() { Ray ray = renderCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, maxRayDistance, draggableLayerMask)) { draggingObject = hit.transform.GetComponent <IDraggable>(); if (draggingObject != null && draggingObject.CanDrag()) { draggingObject.HightlightAvailableForDrag(); } } if (Input.GetMouseButtonDown(0)) { CheckIfCanDrag(ray); } if (Input.GetMouseButtonUp(0)) { if (isMouseDragging) { ReleaseDraggingItem(); } else { ReleaseBagUI(); } } if (isMouseDragging && draggingObject != null) { DragItem(ray); } }