internal override void touchesMoved(List <TKTouch> touches) { if ((base.state == TKGestureRecognizerState.RecognizedAndStillRecognizing) || (base.state == TKGestureRecognizerState.Began)) { float current = TKRotationRecognizer.angleBetweenPoints(this.targetPosition, base._trackingTouches[0].position); base.deltaRotation = Mathf.DeltaAngle(current, base._previousRotation); base._previousRotation = current; base.state = TKGestureRecognizerState.RecognizedAndStillRecognizing; } }
internal override bool touchesBegan(List <TKTouch> touches) { if (base.state == TKGestureRecognizerState.Possible) { base._trackingTouches.Add(touches[0]); base.deltaRotation = 0f; base._previousRotation = TKRotationRecognizer.angleBetweenPoints(this.targetPosition, base._trackingTouches[0].position); base.state = TKGestureRecognizerState.Began; } return(false); }
private bool _hasActiveSimulatedTouch; // are we currently simulating multitouch with active touches (mouse is down)? /// <summary> /// returns true if mouse input should be processed as touch input. it will be true when the Unity Remote is not active. /// </summary> private bool shouldProcessMouseInput() { // check to see if the Unity Remote is active if (!_isUnityRemoteActive && Input.touchCount > 0) { Debug.LogWarning("disabling mouse input because we detected a Unity Remote connected"); _isUnityRemoteActive = true; } // if Unity remote is not active and alt is being held down we are simulating multitouch if (!_isUnityRemoteActive && (Input.GetKey(KeyCode.LeftAlt) || Input.GetKeyUp(KeyCode.LeftAlt))) { // record our start position when alt is pressed if (Input.GetKeyDown(KeyCode.LeftAlt)) { _simulatedMultitouchStartPosition = Input.mousePosition; _isSimulatingMultitouch = true; } else if (Input.GetKeyUp(KeyCode.LeftAlt)) { _hasActiveSimulatedTouch = false; _isSimulatingMultitouch = false; } else { // a mouse down now results in two touches being created. first we setup the position of the touches based on the original point when alt was pressed var radius = Vector3.Distance(Input.mousePosition, _simulatedMultitouchStartPosition); var angle = TKRotationRecognizer.angleBetweenPoints(_simulatedMultitouchStartPosition, Input.mousePosition); angle = Mathf.Deg2Rad * angle; var opposite = Mathf.Sin(angle) * radius; var adjacent = Mathf.Cos(angle) * radius; _simulatedMousePosition = new Vector3(_simulatedMultitouchStartPosition.x - adjacent, _simulatedMultitouchStartPosition.y - opposite); // if we get a mouse down event its time to populate the touches if (Input.GetMouseButtonUp(0) || Input.GetMouseButton(0)) { _hasActiveSimulatedTouch = true; _liveTouches.Add(_touchCache[0].populateFromMouse()); _liveTouches.Add(_touchCache[1].populateFromMouseAtPosition(_simulatedMousePosition)); } else { _hasActiveSimulatedTouch = false; } } } return(!_isUnityRemoteActive); }