Clean-up of ScrollSnapBase

pull/413/head
Simon Jackson 2023-01-01 13:22:53 +00:00
parent c61e5b7e7c
commit eceaa87e93
1 changed files with 11 additions and 15 deletions

View File

@ -13,9 +13,7 @@ namespace UnityEngine.UI.Extensions
internal Rect panelDimensions;
internal RectTransform _screensContainer;
internal bool _isVertical;
internal int _screens = 1;
internal float _scrollStartPosition;
internal float _childSize;
private float _childPos, _maskSize;
@ -26,7 +24,6 @@ namespace UnityEngine.UI.Extensions
internal bool _pointerDown = false;
internal bool _settled = true;
internal Vector3 _startPosition = new Vector3();
[Tooltip("The currently active page")]
internal int _currentPage;
internal int _previousPage;
internal int _halfNoVisibleItems;
@ -36,7 +33,7 @@ namespace UnityEngine.UI.Extensions
private int _bottomItem, _topItem;
internal bool _startEventCalled = false;
internal bool _endEventCalled = false;
internal bool _suspendEvents = false;
internal bool _suspendEvents = false;
[Serializable]
public class SelectionChangeStartEvent : UnityEvent { }
@ -67,25 +64,25 @@ namespace UnityEngine.UI.Extensions
public float transitionSpeed = 7.5f;
[Tooltip("Hard Swipe forces to swiping to the next / previous page (optional)")]
public Boolean UseHardSwipe = false;
public bool UseHardSwipe = false;
[Tooltip("Fast Swipe makes swiping page next / previous (optional)")]
public Boolean UseFastSwipe = false;
public bool UseFastSwipe = false;
[Tooltip("Swipe Delta Threshold looks at the speed of input to decide if a swipe will be initiated (optional)")]
public Boolean UseSwipeDeltaThreshold = false;
public bool UseSwipeDeltaThreshold = false;
[Tooltip("Offset for how far a swipe has to travel to initiate a page change (optional)")]
public int FastSwipeThreshold = 100;
[Tooltip("Speed at which the ScrollRect will keep scrolling before slowing down and stopping (optional)")]
public int SwipeVelocityThreshold = 100;
[Tooltip("Threshold for swipe speed to initiate a swipe, below threshold will return to closest page (optional)")]
public float SwipeDeltaThreshold = 5.0f;
[Tooltip("Use time scale instead of unscaled time (optional)")]
public Boolean UseTimeScale = true;
[Tooltip("Use time scale instead of unscaled time (optional)")]
public bool UseTimeScale = true;
[Tooltip("The visible bounds area, controls which items are visible/enabled. *Note Should use a RectMask. (optional)")]
public RectTransform MaskArea;
@ -167,7 +164,6 @@ namespace UnityEngine.UI.Extensions
private SelectionChangeEndEvent m_OnSelectionChangeEndEvent = new SelectionChangeEndEvent();
public SelectionChangeEndEvent OnSelectionChangeEndEvent { get { return m_OnSelectionChangeEndEvent; } set { m_OnSelectionChangeEndEvent = value; } }
// Use this for initialization
void Awake()
{
if (_scroll_rect == null)
@ -185,7 +181,7 @@ namespace UnityEngine.UI.Extensions
vscroll.ss = this;
}
panelDimensions = gameObject.GetComponent<RectTransform>().rect;
if (StartingScreen < 0)
{
StartingScreen = 0;
@ -414,7 +410,7 @@ namespace UnityEngine.UI.Extensions
else
{
_infiniteOffset = _screensContainer.anchoredPosition.x < 0 ? -_screensContainer.sizeDelta.x * _infiniteWindow : _screensContainer.sizeDelta.x * _infiniteWindow;
_infiniteOffset = _infiniteOffset == 0 ? 0 : _infiniteOffset < 0 ? _infiniteOffset - _childSize * _infiniteWindow : _infiniteOffset + _childSize * _infiniteWindow;
_infiniteOffset = _infiniteOffset == 0 ? 0 : _infiniteOffset < 0 ? _infiniteOffset - _childSize * _infiniteWindow : _infiniteOffset + _childSize * _infiniteWindow;
target.x = _childPos + _scrollStartPosition + _infiniteOffset;
}
}
@ -647,4 +643,4 @@ namespace UnityEngine.UI.Extensions
#endregion
}
}
}