Fixed issues with HSS/VSS in conjunction with the UI_Infinite Scroll
* Vertical Scroller now works with infinite ScrollSnapBase * Resolved issue with Procedural scrollers used with infinite ScrollSnapBase * Resolved issue with UI Infinite scroll which couldn't handle content in reverse orderpull/413/head
parent
0a5444b22b
commit
162bb7ca56
|
@ -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 Infinite scroller attached to the control
|
internal bool _isInfinite; // 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;
|
||||||
|
@ -82,8 +82,8 @@ namespace UnityEngine.UI.Extensions
|
||||||
[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 Boolean 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;
|
||||||
|
@ -100,7 +100,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (_isInfinate)
|
if (_isInfinite)
|
||||||
{
|
{
|
||||||
//Work out which infinite window we are in
|
//Work out which infinite window we are in
|
||||||
float infWindow = (float)value / (float)_screensContainer.childCount;
|
float infWindow = (float)value / (float)_screensContainer.childCount;
|
||||||
|
@ -199,7 +199,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
if (PrevButton)
|
if (PrevButton)
|
||||||
PrevButton.GetComponent<Button>().onClick.AddListener(() => { PreviousScreen(); });
|
PrevButton.GetComponent<Button>().onClick.AddListener(() => { PreviousScreen(); });
|
||||||
|
|
||||||
_isInfinate = GetComponent<UI_InfiniteScroll>() != null;
|
_isInfinite = GetComponent<UI_InfiniteScroll>() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void InitialiseChildObjects()
|
internal void InitialiseChildObjects()
|
||||||
|
@ -213,6 +213,11 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
InitialiseChildObjectsFromArray();
|
InitialiseChildObjectsFromArray();
|
||||||
|
|
||||||
|
if (GetComponent<UI_InfiniteScroll>() != null)
|
||||||
|
{
|
||||||
|
GetComponent<UI_InfiniteScroll>().Init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -307,7 +312,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
//Function for switching screens with buttons
|
//Function for switching screens with buttons
|
||||||
public void NextScreen()
|
public void NextScreen()
|
||||||
{
|
{
|
||||||
if (_currentPage < _screens - 1 || _isInfinate)
|
if (_currentPage < _screens - 1 || _isInfinite)
|
||||||
{
|
{
|
||||||
if (!_lerp) StartScreenChange();
|
if (!_lerp) StartScreenChange();
|
||||||
|
|
||||||
|
@ -322,7 +327,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
//Function for switching screens with buttons
|
//Function for switching screens with buttons
|
||||||
public void PreviousScreen()
|
public void PreviousScreen()
|
||||||
{
|
{
|
||||||
if (_currentPage > 0 || _isInfinate)
|
if (_currentPage > 0 || _isInfinite)
|
||||||
{
|
{
|
||||||
if (!_lerp) StartScreenChange();
|
if (!_lerp) StartScreenChange();
|
||||||
|
|
||||||
|
@ -439,7 +444,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
private void ToggleNavigationButtons(int targetScreen)
|
private void ToggleNavigationButtons(int targetScreen)
|
||||||
{
|
{
|
||||||
//If this is using an Infinite Scroll, then don't disable
|
//If this is using an Infinite Scroll, then don't disable
|
||||||
if (!_isInfinate)
|
if (!_isInfinite)
|
||||||
{
|
{
|
||||||
if (PrevButton)
|
if (PrevButton)
|
||||||
{
|
{
|
||||||
|
@ -500,6 +505,11 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
PageStep = 9;
|
PageStep = 9;
|
||||||
}
|
}
|
||||||
|
var infiniteScroll = GetComponent<UI_InfiniteScroll>();
|
||||||
|
if (ChildObjects != null && ChildObjects.Length > 0 && infiniteScroll != null && !infiniteScroll.InitByUser)
|
||||||
|
{
|
||||||
|
Debug.LogError("When using procedural children with a ScrollSnap (Adding Prefab ChildObjects) and the Infinite Scroll component\nYou must set the 'InitByUser' option to true, to enable late initialising");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -97,12 +97,20 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
if (_isVertical)
|
if (_isVertical)
|
||||||
{
|
{
|
||||||
_recordOffsetY = items[0].GetComponent<RectTransform>().anchoredPosition.y - items[1].GetComponent<RectTransform>().anchoredPosition.y;
|
_recordOffsetY = items[1].GetComponent<RectTransform>().anchoredPosition.y - items[0].GetComponent<RectTransform>().anchoredPosition.y;
|
||||||
|
if (_recordOffsetY < 0)
|
||||||
|
{
|
||||||
|
_recordOffsetY *= -1;
|
||||||
|
}
|
||||||
_disableMarginY = _recordOffsetY * _itemCount / 2;// _scrollRect.GetComponent<RectTransform>().rect.height/2 + items[0].sizeDelta.y;
|
_disableMarginY = _recordOffsetY * _itemCount / 2;// _scrollRect.GetComponent<RectTransform>().rect.height/2 + items[0].sizeDelta.y;
|
||||||
}
|
}
|
||||||
if (_isHorizontal)
|
if (_isHorizontal)
|
||||||
{
|
{
|
||||||
_recordOffsetX = items[1].GetComponent<RectTransform>().anchoredPosition.x - items[0].GetComponent<RectTransform>().anchoredPosition.x;
|
_recordOffsetX = items[1].GetComponent<RectTransform>().anchoredPosition.x - items[0].GetComponent<RectTransform>().anchoredPosition.x;
|
||||||
|
if (_recordOffsetX < 0)
|
||||||
|
{
|
||||||
|
_recordOffsetX *= -1;
|
||||||
|
}
|
||||||
_disableMarginX = _recordOffsetX * _itemCount / 2;//_scrollRect.GetComponent<RectTransform>().rect.width/2 + items[0].sizeDelta.x;
|
_disableMarginX = _recordOffsetX * _itemCount / 2;//_scrollRect.GetComponent<RectTransform>().rect.width/2 + items[0].sizeDelta.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue