public void OnPointerUp(PointerEventData eventData) { handleTransform.position = pointerStartPosition; UIVirtualInput.UpdateInput(VIRTUAL_JOYSTICK_HORIZONTAL_VALUE, 0); UIVirtualInput.UpdateInput(VIRTUAL_JOYSTICK_VERTICAL_VALUE, 0); }
private void UpdateInput(Vector3 pointerDelta, float pointerMovementRange) { pointerDelta.Normalize(); pointerDelta *= pointerMovementRange; UIVirtualInput.UpdateInput(VIRTUAL_JOYSTICK_HORIZONTAL_VALUE, pointerDelta.x); UIVirtualInput.UpdateInput(VIRTUAL_JOYSTICK_VERTICAL_VALUE, pointerDelta.y); }
private void UpdateVerticalInput() { if (endTouchPosition.y > startTouchPosition.y + 200) { UIVirtualInput.UpdateInput(VERTICAL_SWIPE_INPUT, 1); } else if (endTouchPosition.y < startTouchPosition.y - 200) { UIVirtualInput.UpdateInput(VERTICAL_SWIPE_INPUT, -1); } else { UIVirtualInput.UpdateInput(VERTICAL_SWIPE_INPUT, 0); } }
private void UpdateHorizontalInput() { if (endTouchPosition.x > startTouchPosition.x + 200) { UIVirtualInput.UpdateInput(HORIZONTAL_SWIPE_INPUT, 1); } else if (endTouchPosition.x < startTouchPosition.x - 200) { UIVirtualInput.UpdateInput(HORIZONTAL_SWIPE_INPUT, -1); } else { UIVirtualInput.UpdateInput(HORIZONTAL_SWIPE_INPUT, 0); } }
private void OnTouchInput() { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { startTouchPosition = Input.GetTouch(0).position; } else if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended) { endTouchPosition = Input.GetTouch(0).position; UpdateHorizontalInput(); UpdateVerticalInput(); } else { UIVirtualInput.UpdateInput(HORIZONTAL_SWIPE_INPUT, 0); UIVirtualInput.UpdateInput(VERTICAL_SWIPE_INPUT, 0); } }
private void OnUnityEditorInput() { if (Input.GetMouseButtonDown(0)) { startTouchPosition = Input.mousePosition; } else if (Input.GetMouseButtonUp(0)) { endTouchPosition = Input.mousePosition; UpdateHorizontalInput(); UpdateVerticalInput(); } else { UIVirtualInput.UpdateInput(HORIZONTAL_SWIPE_INPUT, 0); UIVirtualInput.UpdateInput(VERTICAL_SWIPE_INPUT, 0); } }
public void OnPointerUp(PointerEventData eventData) { handleTransform.localScale = new Vector3(1f, 1f, 1f); UIVirtualInput.UpdateInput(Input(), 0); }
public void OnPointerDown(PointerEventData eventData) { handleTransform.position = eventData.position; handleTransform.localScale = new Vector3(.9f, .9f, .9f); UIVirtualInput.UpdateInput(Input(), 1); }