/// if the sprite was dragged, return move amount in screen coordinates. /// return the zero vector if dragging happened outside of the sprite public Vector3 movementIfDragged() { if (input.touchCount > 0 && input.hasMoved(0)) { var touch = input.GetTouch(0); if (!sprite.Contains(Camera.main, touch.position)) { return(Vector3.zero); } return(new Vector3(touch.deltaPosition.x, touch.deltaPosition.y, 0f)); } return(Vector3.zero); }
IList <Touch> touchesFor(ICollection <TouchPhase> phases) { var touches = new List <Touch>(); for (int i = 0; i < input.touchCount; i++) { var touch = input.GetTouch(i); if (phases.Contains(touch.phase)) { touches.Add(touch); } } return(touches); }