private void LongPressGestureUpdated(DigitalRubyShared.GestureRecognizer r) { Camera camera; FingersScript.StartOrResetGesture(r, BringToFront, Cameras, gameObject, spriteRenderer, GestureRecognizerComponentScriptBase.GestureObjectMode.RequireIntersectWithGameObject, out camera); if (r.State == GestureRecognizerState.Began) { transform.localScale *= DragScale; panZ = camera.WorldToScreenPoint(transform.position).z; panOffset = transform.position - ScreenToWorldPoint(camera, r.FocusX, r.FocusY, panZ); if (DragStarted != null) { DragStarted.Invoke(this, System.EventArgs.Empty); } } else if (r.State == GestureRecognizerState.Executing) { Vector3 gestureScreenPoint = new Vector3(r.FocusX, r.FocusY, panZ); Vector3 gestureWorldPoint = ScreenToWorldPoint(camera, gestureScreenPoint.x, gestureScreenPoint.y, gestureScreenPoint.z) + panOffset; if (rigidBody != null) { rigidBody.MovePosition(gestureWorldPoint); } else if (rigidBody2D != null) { rigidBody2D.MovePosition(gestureWorldPoint); } else { transform.position = gestureWorldPoint; } if (DragUpdated != null) { DragUpdated.Invoke(this, System.EventArgs.Empty); } } else if (r.State == GestureRecognizerState.Ended) { transform.localScale /= DragScale; if (spriteRenderer != null && BringToFront) { spriteRenderer.sortingOrder = startSortOrder; } if (DragEnded != null) { DragEnded.Invoke(this, System.EventArgs.Empty); } } }
private void LongPressGestureUpdated(GestureRecognizer r) { FingersPanRotateScaleComponentScript.StartOrResetGesture(r, BringToFront, Camera, gameObject, spriteRenderer, GestureRecognizerComponentScriptBase.GestureObjectMode.RequireIntersectWithGameObject); if (r.State == GestureRecognizerState.Began) { panZ = Camera.WorldToScreenPoint(transform.position).z; panOffset = transform.position - Camera.ScreenToWorldPoint(new Vector3(r.FocusX, r.FocusY, panZ)); if (DragStarted != null) { DragStarted.Invoke(this, System.EventArgs.Empty); } } if (r.State == GestureRecognizerState.Executing) { Vector3 gestureScreenPoint = new Vector3(r.FocusX, r.FocusY, panZ); Vector3 gestureWorldPoint = Camera.ScreenToWorldPoint(gestureScreenPoint) + panOffset; if (rigidBody == null) { transform.position = gestureWorldPoint; } else { rigidBody.MovePosition(gestureWorldPoint); } if (DragUpdated != null) { DragUpdated.Invoke(this, System.EventArgs.Empty); } } else if (r.State == GestureRecognizerState.Ended) { if (spriteRenderer != null && BringToFront) { spriteRenderer.sortingOrder = startSortOrder; } if (DragEnded != null) { DragEnded.Invoke(this, System.EventArgs.Empty); } } }
public void OnDrag(PointerEventData eventData) { DragUpdated?.Invoke(eventData, gameObject); }