Пример #1
0
    void Update()
    {
        int count = Input.touchCount;

        if (count == 0)
        {
            touching = false;
            touchId  = -1;
        }
        else
        {
            for (int i = 0; i < count; i++)
            {
                Touch touch = Input.GetTouch(i);

                if (touchArea.Contains(touch.position) &&
                    (touchId == -1 || touchId != touch.fingerId))
                {
                    touchId = touch.fingerId;
                }

                if (touchId == touch.fingerId)
                {
                    if (touch.phase == TouchPhase.Ended ||
                        touch.phase == TouchPhase.Canceled)
                    {
                        touching = false;
                        touchId  = -1;
                    }
                    else
                    {
                        touching = true;
                    }
                }
            }
        }

        if (touching)
        {
            flipper.FlipperUp();
        }
        else
        {
            flipper.FlipperDown();
        }
    }