void InitTouchSystem() { // Pan PanRecognizer panRecognizer = new PanRecognizer(); panRecognizer.gestureCanTrigger = () => { bool isInViewport = geoCamera.IsInViewport(); if (!isInViewport) { return(false); } if (state == GeoState.Normal) { return(canCameraRotate); } return(currentOperation.CanRotateCamera); }; panRecognizer.gestureBeginEvent += (r) => { isCameraRotate = true; geoUI.activePanel.Clear(); }; panRecognizer.gestureRecognizedEvent += (r) => { Vector2 delta = -(r.deltaPosition) * 0.1f; geoCamera.Rotate(delta); }; panRecognizer.gestureEndEvent += (r) => { isCameraRotate = false; }; TouchSystem.addRecognizer(panRecognizer); }
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); }
void Start() { demoCamera = FindObjectOfType(typeof(DemoCamera)) as DemoCamera; TapRecognizer tapRecognizer = new TapRecognizer(); tapRecognizer.zIndex = 1; tapRecognizer.gestureRecognizedEvent += r => { Debug.Log("Tap: " + r); }; PanRecognizer panRecognizer = new PanRecognizer(); panRecognizer.zIndex = 2; panRecognizer.gestureBeginEvent += r => { Debug.Log("Pan Begin -----: " + r); }; panRecognizer.gestureRecognizedEvent += r => { Debug.Log("Pan : " + r); demoCamera.Rotate(-(r.deltaPosition) * 0.1f); }; panRecognizer.gestureEndEvent += r => { Debug.Log("Pan End -----: " + r); }; PanRecognizer panTwoRecognizer = new PanRecognizer(2); panTwoRecognizer.zIndex = 3; panTwoRecognizer.gestureBeginEvent += r => { Debug.Log("Pan Two Begin -----: " + r); }; panTwoRecognizer.gestureRecognizedEvent += r => { Debug.Log("Pan Two : " + r); demoCamera.Move(r.deltaPosition * 0.05f); }; panTwoRecognizer.gestureEndEvent += r => { Debug.Log("Pan Two End -----: " + r); }; PinchRecognizer pinchRecognizer = new PinchRecognizer(); pinchRecognizer.zIndex = 4; pinchRecognizer.gestureBeginEvent += r => { Debug.Log("Pinch Begin -----: " + r); }; pinchRecognizer.gestureRecognizedEvent += r => { Debug.Log("Pinch : " + r); demoCamera.Zoom(r.deltaDistance * 0.05f); }; pinchRecognizer.gestureEndEvent += r => { Debug.Log("Pinch End -----: " + r); }; TouchSystem.addRecognizer(tapRecognizer); TouchSystem.addRecognizer(panRecognizer); TouchSystem.addRecognizer(panTwoRecognizer); TouchSystem.addRecognizer(pinchRecognizer); }