Example #1
0
    public void OnDrag(PointerEventData eventData)
    {
        if (LoopScrollRect != null && !isDragSelf)
        {
            if (Mathf.Abs(eventData.delta.x) > value_MinDrag && Mathf.Abs(eventData.delta.x) > Mathf.Abs(eventData.delta.y))
            {
                LoopScrollRect.OnDrag(eventData);
                return;
            }
        }
        if (isDragOut)
        {
            //如果已经拖出了,不再判定
            return;
        }
        yTotalChange += eventData.delta.y;
        xTotalChange += eventData.delta.x;
        if (Mathf.Abs(yTotalChange) > totalThrehold)
        {
            //累计y值变化超过阈值认为是单体滑动
            isDragSelf = true;
        }
        Vector3 GlobalVariableMousePos;

        if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_DragPlane, eventData.position, eventData.pressEventCamera, out GlobalVariableMousePos))
        {
            selfRectTransform.position = GlobalVariableMousePos - temp;
        }
        if (!RectTransformUtility.RectangleContainsScreenPoint(m_DragPlane, eventData.position, eventData.pressEventCamera)) //判定鼠标点是否不在当前Button的框内了
        {                                                                                                                    //判断第二个参数代表的位置是否在第一个参数rect的范围内
            //StaticData.DebugGreen($"拖出区域外  eventData.position:{eventData.position}");
            if (yTotalChange > totalThrehold)                                                                                //上边拖出来了面板
            {
                actionFromUpDrag?.Invoke(eventData);
                isDragOut = true;
            }
            else if (yTotalChange < -totalThrehold)//下边拖出来了面板
            {
                actionFromBottomDrag?.Invoke(eventData);
                isDragOut = true;
            }
            else if (!isHaveScrollHorizen && xTotalChange > totalThrehold)//右边拖出来了面板
            {
                actionFromRightDrag?.Invoke(eventData);
                isDragOut = true;
            }
            else if (!isHaveScrollHorizen && xTotalChange < -totalThrehold)//左边拖出来了面板
            {
                actionFromLeftDrag?.Invoke(eventData);
                isDragOut = true;
            }
        }
    }
    public void OnDrag(PointerEventData eventData)
    {
        //Debug.Log("OnDrag");
        if (mScrollRect != null)
        {
            mScrollRect.OnDrag(eventData);
        }

        if (mMouseDrag != null)
        {
            mMouseDrag(gameObject, eventData);
        }
    }
 public void OnDrag(PointerEventData eventData)
 {
     //if (Parent = this.gameObject) {
     scrollRect.OnDrag(eventData);
     //}
 }