/* Initialize the corresponding handlers for the selected controlling mode * * The unused handler will be assigned a dummy function to * prevent the handling of the event. */ private void InitializeInputFunction() { Func <float> getAligningDistance = () => _deltaDistanceToCenter; Func <PositionState> getPositionState = () => _positionState; var overGoingThreshold = unitPos * 0.3f; switch (controlMode) { case ControlMode.Drag: _movementCtrl = new FreeMovementCtrl( boxMovementCurve, alignMiddle, overGoingThreshold, getAligningDistance, getPositionState); _inputPositionHandler = DragPositionHandler; _scrollHandler = (Vector2 v) => { }; break; case ControlMode.Function: _movementCtrl = new UnitMovementCtrl( boxMovementCurve, overGoingThreshold, getAligningDistance, getPositionState); _inputPositionHandler = (PointerEventData pointer, TouchPhase phase) => { }; _scrollHandler = (Vector2 v) => { }; break; case ControlMode.MouseWheel: _movementCtrl = new UnitMovementCtrl( boxMovementCurve, overGoingThreshold, getAligningDistance, getPositionState); _inputPositionHandler = (PointerEventData pointer, TouchPhase phase) => { }; _scrollHandler = ScrollDeltaHandler; break; } }
/// <summary> /// Initialize the corresponding handlers for the selected controlling mode /// </summary> /// The unused handler will be assigned a dummy function to /// prevent the handling of the event. private void InitializeInputFunction() { float GetAligningDistance() => _deltaDistanceToCenter; PositionState GetPositionState() => _positionState; var overGoingThreshold = unitPos * 0.3f; switch (_listSetting.controlMode) { case CircularScrollingList.ControlMode.Drag: _movementCtrl = new FreeMovementCtrl( _listSetting.boxVelocityCurve, _listSetting.alignMiddle, overGoingThreshold, GetAligningDistance, GetPositionState); _inputPositionHandler = DragPositionHandler; _scrollHandler = v => { }; break; case CircularScrollingList.ControlMode.Function: _movementCtrl = new UnitMovementCtrl( _listSetting.boxMovementCurve, overGoingThreshold, GetAligningDistance, GetPositionState); _inputPositionHandler = (pointer, phase) => { }; _scrollHandler = v => { }; break; case CircularScrollingList.ControlMode.MouseWheel: _movementCtrl = new UnitMovementCtrl( _listSetting.boxMovementCurve, overGoingThreshold, GetAligningDistance, GetPositionState); _inputPositionHandler = (pointer, phase) => { }; _scrollHandler = ScrollDeltaHandler; _scrollFactor = _listSetting.reverseDirection ? -1 : 1; break; } // It is ok to set _scrollHandler here without mode checking, // because it is only invoked when in mouse scrolling mode. switch (_listSetting.direction) { case CircularScrollingList.Direction.Vertical: _getFactor = FactorUtility.GetVector2Y; _scrollDirectionHandler = ScrollVertically; break; case CircularScrollingList.Direction.Horizontal: _getFactor = FactorUtility.GetVector2X; _scrollDirectionHandler = ScrollHorizontally; break; } _selectionDistanceFactor = _listSetting.reverseOrder ? -1 : 1; }