TwistGesture(TwistGestureRecognizer recognizer, CommonTouch touch1, CommonTouch touch2) : base(recognizer) { fingerId1 = touch1.fingerId; fingerId2 = touch2.fingerId; startPosition1 = touch1.position; startPosition2 = touch2.position; }
public bool Update(CommonTouch touch) { _LastTouch = _ThisTouch; _ThisTouch = touch; switch (_ThisTouch.phase) { case TouchPhase.Began: _BeginTouch = _ThisTouch; _HasMoved = false; break; case TouchPhase.Moved: if (!_HasMoved && !IsInScope(_BeginTouch.position, _ThisTouch.position)) { _HasMoved = true; } break; case TouchPhase.Stationary: break; case TouchPhase.Ended: _EndTouch = _ThisTouch; break; } return(true); }
// public static bool HasAnyTouch() // { //#if UNITY_IPHONE || UNITY_ANDROID // return Input.touchCount > 0; //#else // return Input.anyKey || Input.anyKeyDown; //#endif // } //#if UNITY_IPHONE || UNITY_ANDROID public bool IsPointerOverUIObject(CommonTouch touch) { if (inputModule != null) { return(inputModule.IsHoveredUI(touch.fingerId)); } return(EventSystem.current.IsPointerOverGameObject(touch.fingerId) || EventSystem.current.currentSelectedGameObject != null); }
bool UpdateTouchStates(float fDeltaTime) { _TouchCount = 0; #if UNITY_IPHONE || UNITY_ANDROID int count = Input.touchCount; for (int i = 0; i < count; ++i) { if (_TouchCount >= MaxTouchCount) { break; } Touch touch = Input.GetTouch(i); CommonTouch ct = new CommonTouch(); ct.isMoushTouch = false; ct.fingerTouch = touch; _TouchStates[_TouchCount].Update(ct); ++_TouchCount; } #else bool has_mouse_touch = Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonUp(1); if (!has_mouse_touch) { return(true); } CommonTouch touch2 = new CommonTouch(); touch2.isMoushTouch = true; touch2.mouseTouch.fingerId = -1; touch2.mouseTouch.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y); if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { touch2.mouseTouch.phase = TouchPhase.Began; } else if (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) { touch2.mouseTouch.phase = TouchPhase.Ended; } else { touch2.mouseTouch.phase = TouchPhase.Moved; } if (_TouchCount < MaxTouchCount) { _TouchStates[_TouchCount].Update(touch2); ++_TouchCount; } //_IsPointerOverUI = IsPointerOverUIObject(touch2); #endif return(true); }
TwoFingerDragGesture(TwoFingerDragGestureRecognizer recognizer, CommonTouch touch1, CommonTouch touch2) : base(recognizer) { fingerId1 = touch1.fingerId; startPosition1 = touch1.position; fingerId2 = touch2.fingerId; startPosition2 = touch2.position; position = (startPosition1 + startPosition2) / 2; }
/// <summary> /// タッチポジションを取得(エディタと実機を考慮) /// </summary> /// <returns>タッチポジション。タッチされていない場合は (0, 0, 0)</returns> public static Vector3 GetTouchPosition() { if (Application.isEditor) { TouchInfo touch = CommonTouch.GetTouch(); if (touch != TouchInfo.None) { return(Input.mousePosition); } } else { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); TouchPosition.x = touch.position.x; TouchPosition.y = touch.position.y; return(TouchPosition); } } return(Vector3.zero); }
DragGesture(DragGestureRecognizer recognizer, CommonTouch touch) : base(recognizer) { fingerId = touch.fingerId; startPosition = touch.position; position = startPosition; }
static T ConvertUsingTwoEnhancedTouch(CommonTouch touch, CommonTouch otherTouch) => s_CreateGestureFromTwoEnhancedTouchFunction(touch.GetEnhancedTouch(), otherTouch.GetEnhancedTouch());
static T ConvertUsingOneEnhancedTouch(CommonTouch touch) => s_CreateGestureFromOneEnhancedTouchFunction(touch.GetEnhancedTouch());