Remaining issues resolved.
Now to double check YT and BB for any remaining unresolved issues --HG-- branch : develop_5.3release
parent
a72c45e02a
commit
94f857d203
|
@ -18,8 +18,7 @@ namespace UnityEngine.UI.Extensions
|
|||
if(MaskArea) CalculateVisible();
|
||||
_lerp = false;
|
||||
_currentPage = StartingScreen - 1;
|
||||
_scrollStartPosition = _screensContainer.localPosition.x;
|
||||
_scroll_rect.horizontalNormalizedPosition = (float)(_currentPage) / (_screens - 1);
|
||||
SetScrollContainerPosition();
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
@ -89,8 +88,9 @@ namespace UnityEngine.UI.Extensions
|
|||
_scroll_rect.horizontalNormalizedPosition = 0;
|
||||
GO.transform.SetParent(_screensContainer);
|
||||
DistributePages();
|
||||
if (MaskArea) UpdateVisible();
|
||||
|
||||
_scroll_rect.horizontalNormalizedPosition = (float)(_currentPage) / (_screens - 1);
|
||||
SetScrollContainerPosition();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -107,26 +107,25 @@ namespace UnityEngine.UI.Extensions
|
|||
return;
|
||||
}
|
||||
_scroll_rect.horizontalNormalizedPosition = 0;
|
||||
var children = _screensContainer.transform;
|
||||
int i = 0;
|
||||
foreach (Transform child in children)
|
||||
{
|
||||
if (i == index)
|
||||
{
|
||||
|
||||
Transform child = _screensContainer.transform.GetChild(index);
|
||||
child.SetParent(null);
|
||||
ChildRemoved = child.gameObject;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
DistributePages();
|
||||
if (MaskArea) UpdateVisible();
|
||||
|
||||
if (_currentPage > _screens - 1)
|
||||
{
|
||||
CurrentPage = _screens - 1;
|
||||
}
|
||||
|
||||
SetScrollContainerPosition();
|
||||
}
|
||||
|
||||
private void SetScrollContainerPosition()
|
||||
{
|
||||
_scrollStartPosition = _screensContainer.localPosition.x;
|
||||
_scroll_rect.horizontalNormalizedPosition = (float)(_currentPage) / (_screens - 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,6 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
|
||||
_screensContainer = _scroll_rect.content;
|
||||
int childCount;
|
||||
if (ChildObjects != null && ChildObjects.Length > 0)
|
||||
{
|
||||
if (_screensContainer.transform.childCount > 0)
|
||||
|
@ -117,20 +116,23 @@ namespace UnityEngine.UI.Extensions
|
|||
Debug.LogError("ScrollRect Content has children, this is not supported when using managed Child Objects\n Either remove the ScrollRect Content children or clear the ChildObjects array");
|
||||
return;
|
||||
}
|
||||
childCount = ChildObjects.Length;
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
ChildObjects[i] = GameObject.Instantiate(ChildObjects[i]);
|
||||
ChildObjects[i].transform.SetParent(_screensContainer.transform);
|
||||
if (MaskArea && ChildObjects[i].activeSelf)
|
||||
{
|
||||
ChildObjects[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
InitialiseChildObjectsFromArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
childCount = ChildObjects.Length;
|
||||
InitialiseChildObjectsFromScene();
|
||||
}
|
||||
|
||||
if (NextButton)
|
||||
NextButton.GetComponent<Button>().onClick.AddListener(() => { NextScreen(); });
|
||||
|
||||
if (PrevButton)
|
||||
PrevButton.GetComponent<Button>().onClick.AddListener(() => { PreviousScreen(); });
|
||||
}
|
||||
|
||||
internal void InitialiseChildObjectsFromScene()
|
||||
{
|
||||
int childCount = _screensContainer.childCount;
|
||||
ChildObjects = new GameObject[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
|
@ -142,11 +144,18 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
if (NextButton)
|
||||
NextButton.GetComponent<Button>().onClick.AddListener(() => { NextScreen(); });
|
||||
|
||||
if (PrevButton)
|
||||
PrevButton.GetComponent<Button>().onClick.AddListener(() => { PreviousScreen(); });
|
||||
internal void InitialiseChildObjectsFromArray()
|
||||
{
|
||||
int childCount = ChildObjects.Length;
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
ChildObjects[i] = GameObject.Instantiate(ChildObjects[i]);
|
||||
ChildObjects[i].transform.SetParent(_screensContainer.transform);
|
||||
if (MaskArea && ChildObjects[i].activeSelf)
|
||||
{
|
||||
ChildObjects[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void CalculateVisible()
|
||||
|
@ -161,7 +170,7 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
void UpdateVisible()
|
||||
internal void UpdateVisible()
|
||||
{
|
||||
int BottomItem = _currentPage - HalfNoVisibleItems < 0 ? 0 : HalfNoVisibleItems;
|
||||
int TopItem = _screensContainer.childCount - _currentPage < HalfNoVisibleItems ? _screensContainer.childCount - _currentPage : HalfNoVisibleItems;
|
||||
|
|
|
@ -18,8 +18,7 @@ namespace UnityEngine.UI.Extensions
|
|||
if(MaskArea) CalculateVisible();
|
||||
_lerp = false;
|
||||
_currentPage = StartingScreen - 1;
|
||||
_scrollStartPosition = _screensContainer.localPosition.y;
|
||||
_scroll_rect.verticalNormalizedPosition = (float)(_currentPage) / (float)(_screens - 1);
|
||||
SetScrollContainerPosition();
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
@ -88,9 +87,11 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
_scroll_rect.verticalNormalizedPosition = 0;
|
||||
GO.transform.SetParent(_screensContainer);
|
||||
InitialiseChildObjectsFromScene();
|
||||
DistributePages();
|
||||
if (MaskArea) UpdateVisible();
|
||||
|
||||
_scroll_rect.verticalNormalizedPosition = (float)(_currentPage) / (_screens - 1);
|
||||
SetScrollContainerPosition();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -107,28 +108,27 @@ namespace UnityEngine.UI.Extensions
|
|||
return;
|
||||
}
|
||||
_scroll_rect.verticalNormalizedPosition = 0;
|
||||
var children = _screensContainer.transform;
|
||||
int i = 0;
|
||||
foreach (Transform child in children)
|
||||
{
|
||||
if (i == index)
|
||||
{
|
||||
|
||||
Transform child = _screensContainer.transform.GetChild(index);
|
||||
child.SetParent(null);
|
||||
ChildRemoved = child.gameObject;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
InitialiseChildObjectsFromScene();
|
||||
DistributePages();
|
||||
if (MaskArea) UpdateVisible();
|
||||
|
||||
if (_currentPage > _screens - 1)
|
||||
{
|
||||
CurrentPage = _screens - 1;
|
||||
}
|
||||
|
||||
_scroll_rect.verticalNormalizedPosition = (float)(_currentPage) / (_screens - 1);
|
||||
SetScrollContainerPosition();
|
||||
}
|
||||
|
||||
private void SetScrollContainerPosition()
|
||||
{
|
||||
_scrollStartPosition = _screensContainer.localPosition.y;
|
||||
_scroll_rect.verticalNormalizedPosition = (float)(_currentPage) / (_screens - 1);
|
||||
}
|
||||
|
||||
#region Interfaces
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue