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