private void OnTouchHeld() { if (pieceStatus != "locked" && Touched == true && Placed == false && NotTouched == true) { Vector3 currentMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector3 dragAmount = (currentMousePosition - touchPoint); Vector3 directionToCurrentMousePosition = currentMousePosition - selectedObject.transform.position; DragSummary dragSummary = new DragSummary(); dragSummary.position = currentMousePosition; dragSummary.amount = dragAmount; dragSummary.direction = directionToCurrentMousePosition; if (dragAmount.magnitude > minimumDragDistance) { selectedObject.SendMessage("OnDrag", dragSummary, SendMessageOptions.DontRequireReceiver); } if (Mathf.Abs(dragAmount.x) > minimumDragDistance) { selectedObject.SendMessage("OnHorizontalDrag", dragSummary, SendMessageOptions.DontRequireReceiver); } if (Mathf.Abs(dragAmount.y) > minimumDragDistance) { selectedObject.SendMessage("OnVerticalDrag", dragSummary, SendMessageOptions.DontRequireReceiver); } } }
private void OnTouchHeld() { foreach (Camera usedCamera in usedCameras) { Vector3 currentTouchPosition = usedCamera.ScreenToWorldPoint(Input.mousePosition); Vector3 dragAmount = (currentTouchPosition - touchPoint); DragSummary dragSummary = new DragSummary(); dragSummary.position = usedCamera.ScreenToWorldPoint(currentTouchPosition); dragSummary.cameraSource = usedCamera; dragSummary.direction = currentTouchPosition - selectedObject.transform.position; dragSummary.amount = dragAmount; selectedObject.SendMessage("OnDrag", dragSummary, SendMessageOptions.DontRequireReceiver); if (Mathf.Abs(dragAmount.x) > minimumDragDistance) { selectedObject.SendMessage("OnHorizontalDrag", dragSummary, SendMessageOptions.DontRequireReceiver); DispatchMessage("OnHorizontalDrag", dragSummary); } if (Mathf.Abs(dragAmount.y) > minimumDragDistance) { selectedObject.SendMessage("OnVerticalDrag", dragSummary, SendMessageOptions.DontRequireReceiver); } } }
public void OnVerticalDrag(DragSummary dragSummary) { if (dragSummary.cameraSource.GetComponent <CameraTypes>().cameraType == CameraTypes.CameraType.UICAMERA) { if (scrollType == ScrollType.VERTICAL && canBeScrolled) { this.scrollableUIObjectManager.MoveVertical(dragSummary.amount * scrollSpeed); } } }
public override void OnDrag(DragSummary dragSummary) { if (usesTopDownView) { lineDrawer.AddLine(new Vector3(dragSummary.position.x, this.transform.position.y, dragSummary.position.z)); } else { lineDrawer.AddLine(new Vector3(dragSummary.position.x, dragSummary.position.y, this.transform.position.z)); } }
public virtual void OnDrag(DragSummary dragSummary) { if (this.canBeDragged) { if (usesTopDownView) { this.transform.position = new Vector3(dragSummary.position.x, this.transform.position.y, dragSummary.position.z); } else { this.transform.position = new Vector3(dragSummary.position.x, dragSummary.position.y, this.transform.position.z); } } }
private void OnMouseDown() { foreach (Camera usedCamera in usedCameras) { Vector3 currentMousePosition = Input.mousePosition; Vector3 drag = (mouseClickPoint - currentMousePosition); mouseClickPoint -= (drag / dragFriction); DragSummary dragSummary = new DragSummary(); dragSummary.position = usedCamera.ScreenToWorldPoint(currentMousePosition); dragSummary.cameraSource = usedCamera; dragSummary.amount = drag; if (selectedObject != null) { selectedObject.SendMessage("OnDrag", dragSummary, SendMessageOptions.DontRequireReceiver); } if (Mathf.Abs(drag.x) > dragDistance) { if (selectedObject != null) { selectedObject.SendMessage("OnHorizontalDrag", dragSummary, SendMessageOptions.DontRequireReceiver); } DispatchMessage("OnHorizontalDrag", dragSummary); } if (Mathf.Abs(drag.y) > dragDistance) { if (selectedObject != null) { selectedObject.SendMessage("OnVerticalDrag", dragSummary, SendMessageOptions.DontRequireReceiver); } } } }
public void OnDrag(DragSummary dragSummary) { this.transform.position += onTouchMoveSpeed * new Vector3(dragSummary.direction.x, dragSummary.direction.y, 0f); }