コード例 #1
0
    private void InitTouch()
    {
        // Pan
        PanRecognizer panRecognizer = new PanRecognizer();

        panRecognizer.zIndex = 2;

        panRecognizer.gestureBeginEvent += (r) =>
        {
            // Debug.Log("Pan Begin : " + r);
        };

        panRecognizer.gestureRecognizedEvent += (r) =>
        {
            if (isUIHandleDrag)
            {
                DragItem(r.position);
                return;
            }

            if (IsPointerOverUIObject())
            {
                isOverUI = true;
            }
            if (isOverUI)
            {
                return;
            }

            if (isEditItemHandleDrag)
            {
            }
            else
            {
                Vector2 delta = -(r.deltaPosition) * 0.1f;
                camera.Rotate(delta);
                studioPanel.SetResetButtonActive(true);
            }
        };

        panRecognizer.gestureEndEvent += r =>
        {
            isUIHandleDrag = false;
            isOverUI       = false;
        };

        PanRecognizer panTwoRecognizer = new PanRecognizer(2);

        panTwoRecognizer.zIndex = 3;
        panTwoRecognizer.gestureRecognizedEvent += (r) =>
        {
            camera.Move(r.deltaPosition * 0.05f);
            studioPanel.SetResetButtonActive(true);
        };

        PinchRecognizer pinchRecognizer = new PinchRecognizer();

        pinchRecognizer.zIndex = 4;

        pinchRecognizer.gestureRecognizedEvent += (r) =>
        {
            camera.Zoom(r.deltaDistance * 0.05f);
            studioPanel.SetResetButtonActive(true);
        };

        TapRecognizer tapRecognizer = new TapRecognizer();

        tapRecognizer.gestureRecognizedEvent += (r) =>
        {
            if (isOverUI)
            {
                isOverUI = false;
                return;
            }
            if (IsPointerOverUIObject())
            {
                return;
            }
            if (isItemEdited)
            {
                return;
            }

            studioPanel.Back();
        };

        TouchSystem.addRecognizer(panRecognizer);
        TouchSystem.addRecognizer(panTwoRecognizer);
        TouchSystem.addRecognizer(pinchRecognizer);
        TouchSystem.addRecognizer(tapRecognizer);
    }