示例#1
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        if (lerpMode == LERP_TO_DEFAULT_BUTTON && eventData.position.x <= defaultButtonThreshold.x) //If lerping_to_delete and pointer is still passed lerping threshold, let it lerp, don't begin drag
        {
            eventData.dragging = false;
        }
        else
        {
            //Get drag distance
            float horizontalDistance = Mathf.Abs(eventData.position.x - eventData.pressPosition.x);
            float verticalDistance   = Mathf.Abs(eventData.position.y - eventData.pressPosition.y);
            lerpMode = NO_LERP;


            //If dragging horizontal is greater than vertical distance
            if (horizontalDistance > verticalDistance)
            {
                parentList.GetScrollRect().enabled = false;
                horizontalScrollRect.enabled = true;
                verticalMode = false;
            }
            else
            {
                parentList.GetScrollRect().enabled = true;
                horizontalScrollRect.enabled = false;
                verticalMode = true;
                parentList.GetScrollRect().OnBeginDrag(eventData);
            }
        }
    }