public override Selectable FindSelectableOnLeft() { Selectable selectable = base.FindSelectableOnLeft(); if (selectable && Application.isPlaying) { AudioUI.PlayAudioSound(UIAudioStateEnum.OnScroll); } return(selectable); }
public override void OnSubmit(BaseEventData eventData) { if (_useSound) { if (_useBackSound) { AudioUI.PlayAudioSound(UIAudioStateEnum.OnBack); } else { AudioUI.PlayAudioSound(UIAudioStateEnum.OnClick); } } OnComplexClick?.Invoke(_item); base.OnSubmit(eventData); }
public override Selectable FindSelectableOnDown() { Selectable selectable = base.FindSelectableOnDown(); if (selectable == null) { selectable = navigation.selectOnRight; } if (selectable != null && selectable.isActiveAndEnabled && selectable.GetComponent <RectTransform>().IsVisibleFrom()) { if (Application.isPlaying && useSound) { AudioUI.PlayAudioSound(UIAudioStateEnum.OnScroll); } return(selectable); } return(null); }
public override void OnPointerClick(PointerEventData eventData) { if (_useSound && interactable) { if (_useBackSound) { AudioUI.PlayAudioSound(UIAudioStateEnum.OnBack, _usePauseInSound); } else { AudioUI.PlayAudioSound(UIAudioStateEnum.OnClick, _usePauseInSound); } OnComplexClick?.Invoke(_item); } if (interactable) { base.OnPointerClick(eventData); } }
private void Update() { //OnScroll(); if (!content || !pivot || items == null || !_isMovement) { return; } float currentPosition = GetRightAxis(content.anchoredPosition); _currentSpeed = Mathf.Abs(currentPosition - _pastPosition); _pastPosition = currentPosition; if (!_isStopping) { if (_isDrag || Mathf.Abs(_currentSpeed) >= maxSpeedForMagnetic) { float distance = Mathf.Infinity; int _pastIndex = _currentIndex; for (int i = 0; i < items.Count; i++) { var item = items[i]; if (item == null) { continue; } var aux = Mathf.Abs(GetRightAxis(pivot.position) - GetRightAxis(item.position)); if (aux < distance) { distance = aux; _currentIndex = i; } } if (_pastIndex != _currentIndex) { ScrollEvent(); AudioUI.PlayAudioSound(UIAudioStateEnum.OnScroll); } } float absoluteSpeed = Mathf.Abs(_currentSpeed); if (!_isDrag && absoluteSpeed < maxSpeedForMagnetic) { InitLerpMovement(); } } if (!_isDrag && _isStopping) { _currentTime += Time.unscaledDeltaTime; float valueLerp = Mathf.Clamp(_currentTime / timeForDeceleration, 0, 1); float newPosition = Mathf.Lerp(GetRightAxis(_initVectorLerp), _stopValue, valueLerp); content.anchoredPosition = _isVertical ? new Vector2(_initVectorLerp.x, newPosition) : new Vector2(newPosition, _initVectorLerp.y); if (newPosition == _stopValue && _currentIndex >= 0 && _currentIndex < items.Count) { FinishMovement(); } } }