Пример #1
0
 public void OnDirChange(GameObject go, SlideVector dir)
 {
     if (dir == SlideVector.down)
     {
         go.SetActive(false);
         closeBtn.gameObject.SetActive(true);
     }
 }
Пример #2
0
    public void OnDrag(GameObject go, PointerEventData data)
    {
        touchSecond = data.position;

        timer += Time.deltaTime;  //计时器

        if (timer > offsetTime)
        {
            touchSecond = data.position; //记录结束下的位置
            Vector2 slideDirection = touchFirst - touchSecond;
            float   x = slideDirection.x;
            float   y = slideDirection.y;

            if (y + SlidingDistance < x && y > -x - SlidingDistance)
            {
                if (currentVector == SlideVector.left)
                {
                    return;
                }

                Debug.Log("left");

                currentVector = SlideVector.left;
            }
            else if (y > x + SlidingDistance && y < -x - SlidingDistance)
            {
                if (currentVector == SlideVector.right)
                {
                    return;
                }

                Debug.Log("right");

                currentVector = SlideVector.right;
            }
            else if (y > x + SlidingDistance && y - SlidingDistance > -x)
            {
                if (currentVector == SlideVector.down)
                {
                    return;
                }

                Debug.Log("down");

                currentVector = SlideVector.down;
            }
            else if (y + SlidingDistance < x && y < -x - SlidingDistance)
            {
                if (currentVector == SlideVector.up)
                {
                    return;
                }

                Debug.Log("up");

                currentVector = SlideVector.up;
            }

            OnDirChange(gameObject, currentVector);

            timer      = 0;
            touchFirst = touchSecond;
        }
    }
Пример #3
0
 public void OnUp(GameObject go, PointerEventData data)
 {
     currentVector = SlideVector.nullVector;
 }