Пример #1
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (AllowedButtons?.Contains(eventData.button) ?? false)
     {
         ReleasedHandlers.ForEach(handler => handler(new DraggableReleasedEventArgs <DraggableT>((DraggableT)this, eventData.button, Container != null)));
     }
 }
Пример #2
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     if (AllowedButtons?.Contains(eventData.button) ?? false)
     {
         Container = null;
         PickedHandlers.ForEach(handler => handler(new DraggablePickedEventArgs <DraggableT>((DraggableT)this, eventData.button)));
     }
 }
Пример #3
0
 public void OnDrag(PointerEventData eventData)
 {
     if (AllowedButtons?.Contains(eventData.button) ?? false)
     {
         if (Camera.main.orthographic)
         {
             transform.position += new Vector3(eventData.delta.x, eventData.delta.y, 0);
         }
         else
         {
             Vector3 screenPosition = Input.mousePosition;
             // Track the current depth of the object in front of the camera.
             // (You could also set this to some fixed constant or stored variable)
             screenPosition.z = Vector3.Dot(transform.position - Camera.main.transform.position, Camera.main.transform.forward);
             // Transform this screen position to a world position,
             // using the camera's transformation & projection/viewport settings.
             // Snap the object to this position.
             transform.position = Camera.main.ScreenToWorldPoint(screenPosition);
         }
         HoldingHandlers.ForEach(handler => handler(new DraggableHoldingEventArgs <DraggableT>((DraggableT)this, eventData.button)));
     }
 }