/// <summary> /// Обновление всех касаний. /// </summary> private static void StaticUpdate() { #if UNITY_EDITOR if (Input.GetMouseButtonDown(0)) { Touch simTouch = GetTouchFromMouse(); simTouch.phase = TouchPhase.Began; var wrapper = new TouchWrapper(simTouch); touchWrappers.Add(simTouch.fingerId, wrapper); TouchStartEvent?.Invoke(wrapper, EventSystem.current.IsPointerOverGameObject()); } if (Input.GetMouseButton(0)) { Touch simTouch = GetTouchFromMouse(); simTouch.phase = TouchPhase.Moved; touchWrappers[0].UpdateTouch(simTouch); } if (Input.GetMouseButtonUp(0)) { Touch simTouch = GetTouchFromMouse(); simTouch.phase = TouchPhase.Ended; touchWrappers[0].UpdateTouch(simTouch); TouchEndEvent?.Invoke( touchWrappers[0], EventSystem.current.IsPointerOverGameObject() ); touchWrappers.Clear(); } lastMousePos = Input.mousePosition; #endif #if UNITY_ANDROID Touch touch; for (int i = 0; i < Input.touchCount; i++) { touch = Input.GetTouch(i); if (touch.phase == TouchPhase.Began) { var wrapper = new TouchWrapper(touch); touchWrappers.Add(touch.fingerId, wrapper); TouchStartEvent?.Invoke( wrapper, EventSystem.current.IsPointerOverGameObject(touch.fingerId) ); } else if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) { touchWrappers[touch.fingerId].UpdateTouch(touch); TouchEndEvent?.Invoke( touchWrappers[touch.fingerId], EventSystem.current.IsPointerOverGameObject(touch.fingerId) ); touchWrappers.Remove(touch.fingerId); } else { touchWrappers[touch.fingerId].UpdateTouch(touch); } } #endif }
private void CheckInput() { if (Input.touchCount > 0 && AbleToInput) { Touch touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { TouchStartEvent?.Invoke(touch.position); _inputSession = true; } if (_inputSession) { if (touch.phase == TouchPhase.Moved) { TouchMoveEvent?.Invoke(touch.position); } if (touch.phase == TouchPhase.Ended) { AbleToInput = false; TouchEndEvent?.Invoke(); _inputSession = false; } } } }
public void TouchEnded(Touch touch) { TouchEndEvent?.Invoke(touch); TouchEndEvent = null; TouchStartEvent = null; TouchMoveEvent = null; TouchMoveEvent = null; }
private void OnTouchEndEvent(TouchEndEvent evt) { EndDrag(); if (HasRegisterUpdater) { ErasureMonoUpdater(); HasRegisterUpdater = false; } }
void HandleTouchEnd3(TouchEndEvent args) { if (pickedNode != null) { StaticSprite2D staticSprite = pickedNode.GetComponent <StaticSprite2D>(); staticSprite.Color = (new Color(1.0f, 1.0f, 1.0f, 1.0f)); // Restore picked sprite color pickedNode.RemoveComponent <ConstraintMouse2D>(); // Remove temporary constraint pickedNode = null; } UnsubscribeFromEvent <TouchMoveEvent>(); UnsubscribeFromEvent <TouchEndEvent>(); }
private void OnTouchEndEvent(TouchEndEvent evt) { if (PlayerManager.IsLocalPlayer(mDMono.gameObject)) { if (AllianceUtil.IsInTransferDart) { return; } //HideSelfSelection(); SelectionLogic.MaxTouches = SelectionLogic.DEFAULT_MAX_TOUCHES; if (evt.target == mDMono.transform) { playerController.TargetingComponent.SetMovementTarget(Vector3.zero, true); } playerController.CharacterComponent.LocomotionComponent.TouchEnded(); } }
private void EndSingleTouch(TouchWrapper touch, Transform target, Vector3 location, Vector3 direction, Vector3 groundPosition, bool hasValidNavPoint) { float singleTouchDuration = Time.time - _singleTouchStartTime; if (singleTouchDuration < TapLength) { if (Time.time - _lastTapTime > DoubleTapLength) { TapEvent tapEvent = (null != target) ? new TapEvent(touch.position, target, location) : new TapEvent(touch.position, location); tapEvent.direction = direction; tapEvent.groundPosition = groundPosition; tapEvent.hasValidNavPoint = hasValidNavPoint; #if BUFFER_SINGLE_TAPS StartCoroutine(QueueSingleTap(tapEvent)); #else _lastTapTime = Time.time; _didDoubleTap = false; RaiseEvent(tapEvent); #endif } else { DoubleTapEvent doubleTapEvent = (null != target) ? new DoubleTapEvent(touch.position, target, location) : new DoubleTapEvent(touch.position, location); doubleTapEvent.direction = direction; DoDoubleTap(doubleTapEvent); } } else if (_touchStartedOnPlayer) { DragFromPlayerGestureEndEvent evt = null; if (target) { evt = new DragFromPlayerGestureEndEvent(touch.position, target); } else { evt = new DragFromPlayerGestureEndEvent(touch.position, location); } evt.direction = direction; evt.groundPosition = groundPosition; RaiseEvent(evt); _touchStartedOnPlayer = false; } TouchEndEvent endEvent = (TouchEndEvent)CodeObjectManager.GetEventManager(typeof(TouchEndEvent)).GetNext();; if (target != null) { endEvent.Initialize(touch.position, target, location); } else { endEvent.Initialize(touch.position, location); } endEvent.direction = direction; endEvent.groundPosition = groundPosition; RaiseEvent(endEvent); CodeObjectManager.GetEventManager(typeof(TouchEndEvent)).Destroy(endEvent); //check for flick gesture float flick_history_check = 1.5f; float time_look_back = 0.0f; int i = 0; int touch_index = m_touch_history_index - 1 > 0 ? m_touch_history_index - 1: TOUCH_HISTORY_LENGTH - 1; Vector3 flick_vel = Vector3.zero; float last_time = _touchHistory[touch_index]._time; Vector3 last_flick = touch.position; while (time_look_back < flick_history_check && i < TOUCH_HISTORY_LENGTH - 1) { if (_touchHistory[touch_index]._time == 0.0f) { break; } float time = last_time - _touchHistory[touch_index]._time; last_time = _touchHistory[touch_index]._time; time_look_back += time; flick_vel += _touchHistory[touch_index]._position - last_flick; last_flick = _touchHistory[touch_index]._position; i++; touch_index = touch_index - 1 > 0 ? touch_index - 1 : TOUCH_HISTORY_LENGTH - 1; } //EB.Debug.Log (i); if (time_look_back > 0.0f) { flick_vel *= time_look_back; if (flick_vel.magnitude > 0.2f) { FlickEvent flickEvent = new FlickEvent(); flickEvent.Initialize(touch.position, flick_vel); RaiseEvent(flickEvent); } else { //EB.Debug.Log ("VEL FAIL"); } } else { //EB.Debug.Log ("TIME FAIL"); } ResetTouchHistory(); }
private void OnTouchEnd(TouchEndEvent touchBeganData) { Stop(); }
void HandleTouchEnd3(TouchEndEvent args) { if (pickedNode != null) { StaticSprite2D staticSprite = pickedNode.GetComponent<StaticSprite2D>(); staticSprite.Color = (new Color(1.0f, 1.0f, 1.0f, 1.0f)); // Restore picked sprite color pickedNode.RemoveComponent<ConstraintMouse2D>(); // Remove temporary constraint pickedNode = null; } UnsubscribeFromEvent<TouchMoveEvent>(); UnsubscribeFromEvent<TouchEndEvent>(); }
void OnTouchEndEvent(TouchEndEvent evt) { }