public void OnEndDrag(PointerEventData eventData) { if (this.i >= CS.Height || this.j >= CS.Width) { return; } Vector2 direction = eventData.position - beginDragPos; int i, j; float lengthX = Mathf.Abs(direction.x); float lengthY = Mathf.Abs(direction.y); if (lengthX > lengthY) { i = this.i; j = this.j + (int)(direction.x / lengthX); } else { i = this.i - (int)(direction.y / lengthY); j = this.j; } game.Swipe(this.i, this.j, i, j); }