void IMixedRealityTouchHandler.OnTouchUpdated(HandTrackingInputEventData eventData) { OnTouchUpdated.Invoke(eventData); if (debugTextTwo != null) { debugTextTwo.text = "OnTouchUpdated: " + Time.unscaledTime.ToString(); } OnTouchUpdated.Invoke(eventData); }
bool OnTouchDown() { if (0 < Input.touchCount) { for (int i = 0; i < Input.touchCount; i++) { Touch t = Input.GetTouch(i); Ray ray = Camera.main.ScreenPointToRay(t.position); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit)) { OnTouched.Invoke(hit.collider.gameObject.name); text.text = hit.collider.gameObject.name; return(true); } else { return(false); } } } text.text = ""; return(false); }
// Update is called once per frame private void Update() { foreach (var touch in Input.touches) { TouchEvent.Invoke(touch); } }
/// @param eventData /// The data of the touch event /// public void OnPointerDown(PointerEventData eventData) { OnTouchedDown.SafeInvoke(eventData.position); m_touched = true; if (m_downEvent != null) { m_downEvent.Invoke(); } }
/// @param eventData /// The data of the touch event /// public void OnPointerEnter(PointerEventData eventData) { m_entered = true; OnTouchEntered.SafeInvoke(); if (m_enterEvent != null) { m_enterEvent.Invoke(); } }
public void Touch(FingerTipCollider finger) { if (onTouch != null) { onTouch.Invoke(finger); } //if (finger.index == 1) //{ //index == 1 means index finger // onPoked.Invoke(); //} }
/// @param eventData /// The data of the touch event /// public void OnPointerExit(PointerEventData eventData) { if (m_entered == true) { m_entered = false; OnTouchExited.SafeInvoke(); if (m_exitEvent != null) { m_exitEvent.Invoke(); } } }
void HandleCamera() { currentPosition = Input.mousePosition; deltaPosition = currentPosition - lastPosition; lastPosition = currentPosition; if (Input.touchCount == 1 && !held_two) { var x = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).rawPosition); acumTime += Input.GetTouch(0).deltaTime; if (acumTime >= holdTime) { held = true; print(x); holdingEvent.Invoke(x); } if (Input.GetTouch(0).phase == TouchPhase.Ended) { if (held) { holdReleaseEvent.Invoke(x); } acumTime = 0; tapEvent.Invoke(x); } } else if (Input.touchCount == 2) { held_two = true; panEvent.Invoke(); Vector2 totalMove = Vector2.zero; foreach (Touch thisTouch in Input.touches) { totalMove += thisTouch.deltaPosition; } /* calculate average movement for each touch */ panMove = totalMove / 2; transform.position = transform.position - new Vector3(0, panMove.y) * speedFactor; if (Input.GetTouch(0).phase == TouchPhase.Ended) { StartCoroutine("DelayTwoToOneTouch"); } } else if (Input.GetKey(KeyCode.E)) // MOUSE DEBUG for dragging { panEvent.Invoke(); panMove = deltaPosition / 2; transform.position = transform.position - new Vector3(0, panMove.y) * speedFactor; } }
void IMixedRealityTouchHandler.OnTouchStarted(HandTrackingInputEventData eventData) { OnTouchStarted.Invoke(eventData); if (debugMessage != null) { debugMessage.text = "OnTouchStarted: " + Time.unscaledTime.ToString(); } if (TargetRenderer != null) { TargetRenderer.sharedMaterial.color = Color.Lerp(originalColor, highlightedColor, 2.0f); } }
void IMixedRealityTouchHandler.OnTouchCompleted(HandTrackingInputEventData eventData) { OnTouchCompleted.Invoke(eventData); if (debugMessage != null) { debugMessage.text = "OnTouchCompleted: " + Time.unscaledTime.ToString(); } if ((TargetRenderer != null) && (TargetRenderer.material != null)) { TargetRenderer.material.color = originalColor; } }
void IMixedRealityTouchHandler.OnTouchUpdated(HandTrackingInputEventData eventData) { OnTouchUpdated.Invoke(eventData); if (debugMessage2 != null) { debugMessage2.text = "OnTouchUpdated: " + Time.unscaledTime.ToString(); } if ((TargetRenderer != null) && (TargetRenderer.material != null)) { TargetRenderer.material.color = Color.Lerp(Color.green, Color.red, t); t = Mathf.PingPong(Time.time, duration) / duration; } }
/// @param eventData /// The data of the touch event /// public void OnPointerUp(PointerEventData eventData) { OnTouchedUp.SafeInvoke(eventData.position); if (m_upEvent != null) { m_upEvent.Invoke(); } if (m_touched == true) { OnTapped.SafeInvoke(eventData.position); if (m_tapEvent != null) { m_tapEvent.Invoke(eventData.position); } } m_touched = false; }
private void UpdateTouch() { if (Input.GetMouseButtonDown(0)) { Vector3 wp = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 touchPos = new Vector2(wp.x, wp.y); var collider = Physics2D.OverlapPoint(touchPos); if (collider) { var tile = collider.GetComponent <Tile>(); if (tile) { TouchEvent?.Invoke(this, new InfoEventArgs <Point>(tile.pos)); } } } }
void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Ended) { RaiseClickTap(Camera.main.ScreenToWorldPoint(touch.position)); if (Time.time < lastClickDeltaTime + DoubleTapCatchTime) { RaiseDoubleTap(); } lastClickDeltaTime = Time.time; } TouchEvent?.Invoke(Camera.main.ScreenToWorldPoint(touch.position)); } }
private void OnTouch(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool newState) => touchEvent?.Invoke(fromAction, fromSource, newState);
public void TriggerNote(Touch touch) { OnNoteTrigger.Invoke(touch); }
public virtual void OnPokeUpdated(TouchPointer touchPointer, SCPointEventData eventData) { PokeUpdated.Invoke(touchPointer, eventData); }
void Update() { SimpleTouch newTouch = new SimpleTouch(); Vector2 newHovered; if (touchMode == TouchMode.Viewport) { newHovered = Camera.main.ScreenToViewportPoint(Input.mousePosition + Vector3.forward * 5); } else// if (touchMode == TouchMode.World) { newHovered = Camera.main.ScreenToWorldPoint(Input.mousePosition + Vector3.forward * 5); } if (Input.GetMouseButton(0)) { touching = true; newTouch.position = newHovered; if (Input.GetMouseButtonDown(0)) { newTouch.phase = SimpleTouch.TouchPhase.Began; newTouch.deltaPosition = Vector2.zero; OnTouchBegin?.Invoke(newTouch); } else { newTouch.deltaPosition = newTouch.position - touch.position; if (newTouch.deltaPosition != Vector2.zero) { newTouch.phase = SimpleTouch.TouchPhase.Moved; } else { newTouch.phase = SimpleTouch.TouchPhase.Stationary; } OnTouchContinue?.Invoke(newTouch); } } else if (Input.GetMouseButtonUp(0)) { touching = false; newTouch.phase = SimpleTouch.TouchPhase.Ended; newTouch.position = touch.position; newTouch.deltaPosition = touch.deltaPosition; OnTouchEnd?.Invoke(newTouch); } else { touching = false; newTouch.phase = SimpleTouch.TouchPhase.Hovered; newTouch.position = newHovered; newTouch.deltaPosition = newTouch.position - touch.position; OnHover?.Invoke(newTouch); } OnTouch?.Invoke(newTouch); touch = newTouch; }
public override bool DispatchTouchEvent(MotionEvent ev) { return((TouchEvent?.Invoke(ev) ?? false) || base.DispatchTouchEvent(ev)); }
void IMixedRealityTouchHandler.OnTouchUpdated(HandTrackingInputEventData eventData) { OnTouchUpdated.Invoke(eventData); }
private void MouseInput() { AdvancedTouch touch; if (Input.GetMouseButtonDown(0)) { if (touchById.ContainsKey(0)) { return; } if (ignoreOverUI && EventSystem.current.IsPointerOverGameObject()) { return; } touch = GetTouch(0, Input.mousePosition); touch.phase = TouchPhase.None; touchById.Add(0, touch); touchEventList.Add(touch.ToTouch()); } else if (Input.GetMouseButton(0)) { if (!touchById.ContainsKey(0)) { return; } touch = touchById[0]; UpdateTouch(touch, Input.mousePosition); if (0.0f < (touch.point - touch.prevPoint).magnitude) { touch.dragLength += (touch.point - touch.prevPoint).magnitude; } else { touch.holdTime += Time.deltaTime; } if (dragTriggerLength < touch.dragLength) { touch.phase = TouchPhase.Drag; } else if (holdTriggerDelay < touch.holdTime) { touch.phase = TouchPhase.Hold; } else { touch.phase = TouchPhase.Down; } touchEventList.Add(touch.ToTouch()); } else if (Input.GetMouseButtonUp(0)) { if (!touchById.ContainsKey(0)) { return; } touch = touchById[0]; touchById.Remove(0); PutTouch(touch); UpdateTouch(touch, Input.mousePosition); switch (touch.phase) { case TouchPhase.Hold: touch.phase = TouchPhase.HoldUp; break; case TouchPhase.Drag: touch.phase = TouchPhase.DragUp; break; default: touch.phase = TouchPhase.Up; break; } touchEventList.Add(touch.ToTouch()); } onTouched.Invoke(touchEventList); touchEventList.Clear(); }
public virtual void OnPokeUp(TouchPointer touchPointer, SCPointEventData eventData) { AudioSystem.getInstance.PlayAudioOneShot(gameObject, PokeUpAudio); PokeUp.Invoke(touchPointer, eventData); }
void IMixedRealityTouchHandler.OnTouchStarted(HandTrackingInputEventData eventData) { OnTouchStarted.Invoke(eventData); Debug.Log("Started"); }