예제 #1
0
    public void OnDrag(PointerEventData eventData)
    {
        if (eventData.button != PointerEventData.InputButton.Left)
        {
            return;
        }

        _dragController.OnDrag(eventData.position);
    }
예제 #2
0
 public void OnDrag(PointerEventData pointerEventData)
 {
     //该回调在拖拽时被调用
     dragController.OnDrag(pointerEventData, this, generalPanelUI);
 }
예제 #3
0
    private void Update()
    {
        // if (!splitController.splitInProgress && !itemActionsUI.dropInProgress)
        // {
        //  if (itemActionsUI.menuActive)
        //  {
        //      if (Input.GetMouseButtonDown(0))
        //      {
        //          if (!ItemActionsHit())
        //          {
        //              itemActionsUI.Close();
        //              DeselectInventorySlot();
        //          }
        //      }
        //
        //      if (Input.GetMouseButtonDown(1))
        //      {
        //          if (!ItemActionsHit())
        //          {
        //              var slotHit = GetSlotHit();
        //              if (slotHit && slotHit.itemInside)
        //              {
        //                  if (slotHit != selectedInventorySlot)
        //                  {
        //                      SelectInventorySlot(slotHit);
        //                      itemActionsUI.OpenActionsFor(slotHit);
        //                  }
        //              }
        //              else
        //              {
        //                  itemActionsUI.Close();
        //                  DeselectInventorySlot();
        //              }
        //          }
        //      }
        //  }
        //  else
        //  {
        if (Input.GetMouseButtonDown(0))
        {
            var slotHit = GetSlotHit();
            if (slotHit && slotHit.itemInside)
            {
                SelectInventorySlot(slotHit);
                dragTime = Time.time + TIME_HOLD_TO_DRAG;
            }
            else
            {
                dragTime = float.MaxValue;
            }
        }
        else
        {
            if (Input.GetMouseButton(0))
            {
                if (Time.time >= dragTime)
                {
                    if (dragController.draggedInventorySlot)
                    {
                        dragController.OnDrag();
                    }
                    else
                    {
                        // itemActionsUI.Close();
                        dragController.BeginDrag(selectedInventorySlot);
                    }
                }
            }
            else if (Input.GetMouseButtonUp(0))
            {
                if (dragController.draggedInventorySlot)
                {
                    var newSlot = dragController.OnEndDrag();
                    if (newSlot)
                    {
                        SelectInventorySlot(newSlot);
                    }
                }
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            if (dragController.draggedInventorySlot)
            {
                dragController.StopDrag();
                dragTime = float.MaxValue;
            }
            else
            {
                var slotHit = GetSlotHit();
                if (slotHit && slotHit.itemInside)
                {
                    SelectInventorySlot(slotHit);
                    // itemActionsUI.OpenActionsFor(slotHit);
                }
            }
        }

        // }
        // }
    }