Updated HSS/VSS to include a new HARD swipe option. Forces scroll snap to ONLy move one page when swiped.
parent
6a4256738a
commit
104002eaa5
File diff suppressed because it is too large
Load Diff
|
@ -150,8 +150,8 @@ RectTransform:
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 1}
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
m_AnchoredPosition: {x: 225.10002, y: -99.100006}
|
m_AnchoredPosition: {x: 298, y: -155.1}
|
||||||
m_SizeDelta: {x: -496.4, y: -233.4}
|
m_SizeDelta: {x: -642.3, y: -345.4}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &2641525
|
--- !u!114 &2641525
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
|
|
@ -239,13 +239,26 @@ namespace UnityEngine.UI.Extensions
|
||||||
if (_scroll_rect.horizontal)
|
if (_scroll_rect.horizontal)
|
||||||
{
|
{
|
||||||
var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition);
|
var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition);
|
||||||
if (UseFastSwipe && distance < panelDimensions.width && distance >= FastSwipeThreshold)
|
if ((UseFastSwipe && distance < panelDimensions.width && distance >= FastSwipeThreshold) || UseHardSwipe)
|
||||||
{
|
{
|
||||||
_scroll_rect.velocity = Vector3.zero;
|
_scroll_rect.velocity = Vector3.zero;
|
||||||
if (_startPosition.x - _screensContainer.localPosition.x > 0)
|
if (_startPosition.x - _screensContainer.localPosition.x > 0)
|
||||||
|
{
|
||||||
|
if (_startPosition.x - _screensContainer.localPosition.x > _childSize / 3)
|
||||||
|
{
|
||||||
|
ScrollToClosestElement();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
NextScreen();
|
NextScreen();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_startPosition.x - _screensContainer.localPosition.x > -_childSize / 3)
|
||||||
|
{
|
||||||
|
ScrollToClosestElement();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PreviousScreen();
|
PreviousScreen();
|
||||||
|
@ -253,6 +266,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,7 +31,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
internal int _previousPage;
|
internal int _previousPage;
|
||||||
internal int _halfNoVisibleItems;
|
internal int _halfNoVisibleItems;
|
||||||
internal bool _moveStarted;
|
internal bool _moveStarted;
|
||||||
internal bool _isInfinate; // Is a UI Infinate scroller attached to the control
|
internal bool _isInfinate; // Is a UI Infinite scroller attached to the control
|
||||||
internal int _infiniteWindow; // The infinite window the control is in
|
internal int _infiniteWindow; // The infinite window the control is in
|
||||||
internal float _infiniteOffset; // How much to offset a repositioning
|
internal float _infiniteOffset; // How much to offset a repositioning
|
||||||
private int _bottomItem, _topItem;
|
private int _bottomItem, _topItem;
|
||||||
|
@ -64,6 +64,9 @@ namespace UnityEngine.UI.Extensions
|
||||||
[Tooltip("Transition speed between pages. (optional)")]
|
[Tooltip("Transition speed between pages. (optional)")]
|
||||||
public float transitionSpeed = 7.5f;
|
public float transitionSpeed = 7.5f;
|
||||||
|
|
||||||
|
[Tooltip("Hard Swipe forces to swiping to the next / previous page (optional)")]
|
||||||
|
public Boolean 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 Boolean UseFastSwipe = false;
|
||||||
|
|
||||||
|
@ -76,7 +79,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
[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;
|
||||||
|
|
||||||
[Tooltip("Pixel size to buffer arround Mask Area. (optional)")]
|
[Tooltip("Pixel size to buffer around Mask Area. (optional)")]
|
||||||
public float MaskBuffer = 1;
|
public float MaskBuffer = 1;
|
||||||
|
|
||||||
public int CurrentPage
|
public int CurrentPage
|
||||||
|
@ -90,7 +93,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
if (_isInfinate)
|
if (_isInfinate)
|
||||||
{
|
{
|
||||||
//Work out which infinate window we are in
|
//Work out which infinite window we are in
|
||||||
_infiniteWindow = value / _screensContainer.childCount;
|
_infiniteWindow = value / _screensContainer.childCount;
|
||||||
//Invert the value if negative and differentiate from Window 0
|
//Invert the value if negative and differentiate from Window 0
|
||||||
_infiniteWindow = value < 0 ? (-_infiniteWindow) + 1 : _infiniteWindow;
|
_infiniteWindow = value < 0 ? (-_infiniteWindow) + 1 : _infiniteWindow;
|
||||||
|
@ -417,7 +420,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
/// <param name="targetScreen"></param>
|
/// <param name="targetScreen"></param>
|
||||||
private void ToggleNavigationButtons(int targetScreen)
|
private void ToggleNavigationButtons(int targetScreen)
|
||||||
{
|
{
|
||||||
//Ifthis is using an Infinate Scoll, then don't disable
|
//If this is using an Infinite Scroll, then don't disable
|
||||||
if (!_isInfinate)
|
if (!_isInfinate)
|
||||||
{
|
{
|
||||||
if (PrevButton)
|
if (PrevButton)
|
||||||
|
@ -518,7 +521,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the Transform of the Currentpage in an out param for performance
|
/// Returns the Transform of the Current page in an out parameter for performance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="returnObject">Currently selected Page Transform</param>
|
/// <param name="returnObject">Currently selected Page Transform</param>
|
||||||
public void CurrentPageObject(out Transform returnObject)
|
public void CurrentPageObject(out Transform returnObject)
|
||||||
|
|
|
@ -239,13 +239,26 @@ namespace UnityEngine.UI.Extensions
|
||||||
if (_scroll_rect.vertical)
|
if (_scroll_rect.vertical)
|
||||||
{
|
{
|
||||||
var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition);
|
var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition);
|
||||||
if (UseFastSwipe && distance < panelDimensions.height + FastSwipeThreshold && distance >=1f)
|
if ((UseFastSwipe && distance < panelDimensions.height + FastSwipeThreshold && distance >=1f) || UseHardSwipe)
|
||||||
{
|
{
|
||||||
_scroll_rect.velocity = Vector3.zero;
|
_scroll_rect.velocity = Vector3.zero;
|
||||||
if (_startPosition.y - _screensContainer.localPosition.y > 0)
|
if (_startPosition.y - _screensContainer.localPosition.y > 0)
|
||||||
|
{
|
||||||
|
if (_startPosition.y - _screensContainer.localPosition.y > _childSize / 3)
|
||||||
|
{
|
||||||
|
ScrollToClosestElement();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
NextScreen();
|
NextScreen();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_startPosition.y - _screensContainer.localPosition.y > -_childSize / 3)
|
||||||
|
{
|
||||||
|
ScrollToClosestElement();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PreviousScreen();
|
PreviousScreen();
|
||||||
|
@ -253,6 +266,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue