Example #1
0
        public bool OnBeginDrag(PointerEventData eventData)
        {
            Vector2 localPoint;

            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.pressPosition, eventData.pressEventCamera, out localPoint))
            {
                if (Vector2.Distance(Vector2.zero, localPoint) <= _pointRadius + _pointSkin)
                {
                    _isDraggingPoint = true;
                    OnDragBegin?.Invoke(this, new EventArgs(eventData, isPointEvent: true));
                    SetDraggedPosition(eventData);
                }
                else if (Vector2.Distance(localPoint, _outHandlePosition) <= _handleRadius + _handleSkin)
                {
                    _isDraggingOutHandle = true;
                    OnDragBegin?.Invoke(this, new EventArgs(eventData, isOutHandleEvent: true));
                    SetDraggedAngle(eventData);
                }
                else if (Vector2.Distance(localPoint, _inHandlePosition) <= _handleRadius + _handleSkin)
                {
                    _isDraggingInHandle = true;
                    OnDragBegin?.Invoke(this, new EventArgs(eventData, isInHandleEvent: true));
                    SetDraggedAngle(eventData);
                }
                else
                {
                    return(!IsEventOutside(eventData));
                }

                return(true);
            }

            return(false);
        }
        void Update_TouchDown()
        {
            if (!HasActiveTouch() || _input.GetTouchCount() > 1)
            {
                _state = State.kIdle;
                return;
            }

            // Touch Cnt must be 1
            if (_input.GetTouchPhase(0) == TouchPhase.Moved)
            {
                Vector2 deltaMove    = _input.GetTouchPosition(0) - _curPos;
                float   deltaMoveDis = deltaMove.magnitude;
                if (deltaMoveDis > MinDragDis)
                {
                    _state = State.kDraging;

                    if (deltaMoveDis > MinDragDis * 3)
                    {
                        if (DragHandler != null)
                        {
                            DragHandler.Invoke(_input.GetTouchPosition(0), deltaMove);
                        }
                    }
                    _curPos = _input.GetTouchPosition(0);

                    if (DragBeginHandler != null)
                    {
                        DragBeginHandler.Invoke(_curPos);
                    }
                }
            }
        }
        private void Timeline_MouseDown(object sender, MouseEventArgs e)
        {
            var rect = new RectangleF(SideRenderOffset, Height / 2 - BarWidth / 2 - 1, (Width - SideRenderOffset * 2) + 1, BarWidth + 2);

            if (rect.Contains(e.Location))
            {
                _dragging = true;

                OnDragBegin.Invoke(this, null);
                Timeline_MouseMove(sender, e);
            }
        }
Example #4
0
 private void Drag()
 {
     if (!isActive)
     {
         return;
     }
     if (!isUse)
     {
         assembleManager.OnSelect.Invoke(this);
         PrepareAssmeble();
     }
     else if (prepareFinish)
     {
         if (Input.GetMouseButtonDown(0))
         {
             Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             RaycastHit hit;
             containerBase = null;
             if (Physics.Raycast(ray, out hit, 100) && hit.transform.name == obj.name)
             {
                 screenPosition  = Camera.main.WorldToScreenPoint(obj.transform.position);
                 mScreenPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z);
                 offset          = obj.transform.position - Camera.main.ScreenToWorldPoint(mScreenPosition);
                 isButtonDown    = true;
             }
             if (OnDragBegin != null)
             {
                 OnDragBegin.Invoke();
             }
         }
         if (Input.GetMouseButton(0) && isButtonDown)
         {
             mScreenPosition        = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z);
             obj.transform.position = Camera.main.ScreenToWorldPoint(mScreenPosition) + offset;
         }
         if (Input.GetMouseButtonUp(0) && isButtonDown)
         {
             isUse         = false;
             isActive      = false;
             isButtonDown  = false;
             tempContainer = FindContainer();
             if (JugeAssmeble(tempContainer))
             {
                 BeginAssmeble(tempContainer);
             }
             if (OnDragEnd != null)
             {
                 OnDragEnd.Invoke(this, containerBase);
             }
         }
     }
 }
Example #5
0
        public void OnBeginDrag(PointerEventData eventData)
        {
            if (IsDraggable == false)
            {
                return;
            }

            SfxManager.Instance.Play(SfxType.UI_DragStart);

            OnDragBegin?.Invoke();

            selectedObject = this;
            startPos       = transform.position;
            IsDragging     = true;
        }
Example #6
0
 protected void Invoke_OnDragBegin(object sender, DragArgs args)
 {
     OnDragBegin?.Invoke(sender, args);
 }
 public void OnBeginDrag(PointerEventData eventData)
 {
     SetDraggedPosition(eventData);
     OnDragBegin?.Invoke(this, new PointerEventArgs(eventData));
 }