public MobileInputState GetNewState(MobileInputState currentState) { MobileInputState newState = currentState; if (Application.isMobilePlatform) { List <Touch> currentTouches = GetTouches(); UpdateTouchPositions(currentTouches); int updatedTouchCount = TouchPositions.Count; if (DidStateChange(updatedTouchCount)) { currentTouchCount = updatedTouchCount; newState = GetMobileInputStateByTouchCount(currentTouchCount); } } else { if (Input.GetMouseButtonDown(0)) { DidRaycastHitSelectionRectCollider(Input.mousePosition); } } return(newState); }
protected override void InitializeInternal(RectTransform transformTarget, BoxCollider2D selectionRectCollider, Camera renderCamera) { InitializePropertyContainer(); currentState = new MobileInputState(transformTarget); stateEvaluator = new MobileInputStateEvaluator(renderCamera, transformTarget, selectionRectCollider, propertyContainer); pointerState = stateEvaluator.GetNewState(currentState); }
public override void UpdateInternal() { MobileInputState newState = stateEvaluator.GetNewState(currentState); if (newState != currentState) { currentState = newState; currentState.AddOnSelectionChangedEvent(GetOnSelectionChangedEvent()); } List <Vector2> touchPositions = stateEvaluator.TouchPositionsWorlCoordinates; currentState.Update(touchPositions); }
private MobileInputState GetMobileInputStateByTouchCount(int touchCount) { MobileInputState mobileInputState = null; if (touchCount == 1) { mobileInputState = new MobileSelectionRectMoveState(selectionRect, selectionRectCollider); } else if (touchCount == 2) { mobileInputState = new MobileSelectionRectScaleState(selectionRect, PropertyContainer); } else { mobileInputState = new MobileInputState(selectionRect); } return(mobileInputState); }