Example #1
0
 public void OnHold(InputAction.CallbackContext context)
 {
     if (context.performed)
     {
         var item = Physics2D.OverlapPoint(_mousePositionInWorldSpace, _draggableLayers);
         if (item)
         {
             var draggable = item.GetComponent <IDraggable>();
             if (draggable != null)
             {
                 _topItemZIndex         -= 0.01f;
                 item.transform.position = new Vector3(item.transform.position.x, item.transform.position.y, _topItemZIndex);
                 _heldItem = draggable;
                 _heldItem.DragStart(_mousePositionInWorldSpace);
             }
         }
     }
     else if (context.canceled && _heldItem != null)
     {
         _heldItem.DragEnd(_mousePositionInWorldSpace);
         _heldItem = null;
     }
 }