Perfromance tweaks for H & V scroll snaps.

Updated create option
Matched Size options from HSS update in to VSS

--HG--
branch : develop_5.3
release
Simon Jackson 2016-11-15 14:52:34 +00:00
parent cb535507a4
commit 2de76cf7a3
3 changed files with 1651 additions and 1649 deletions

File diff suppressed because it is too large Load Diff

View File

@ -49,9 +49,10 @@ namespace UnityEngine.UI.Extensions
[SerializeField]
public int StartingScreen = 1;
[Tooltip("The distance between two pages, by default 3 times the width of the control")]
[Tooltip("The distance between two pages based on page height, by default 3 times the width of the control")]
[SerializeField]
public int PageStep = 0;
[Range(0, 8)]
public float PageStep = 0;
public int CurrentPage
{
@ -74,10 +75,7 @@ namespace UnityEngine.UI.Extensions
}
_screensContainer = _scroll_rect.content;
if (PageStep == 0)
{
PageStep = (int)_scroll_rect.GetComponent<RectTransform>().rect.width * PageStep;
}
DistributePages();
_lerp = false;
@ -229,14 +227,16 @@ namespace UnityEngine.UI.Extensions
private void DistributePages()
{
int _offset = 0;
int _dimension = 0;
float _dimension = 0;
Rect panelDimensions = gameObject.GetComponent<RectTransform>().rect;
int currentXPosition = 0;
float currentXPosition = 0;
var pageStepValue = (int)panelDimensions.width * ((PageStep == 0) ? 3 : PageStep);
for (int i = 0; i < _screensContainer.transform.childCount; i++)
{
RectTransform child = _screensContainer.transform.GetChild(i).gameObject.GetComponent<RectTransform>();
currentXPosition = _offset + (int)(i * PageStep);
currentXPosition = _offset + (int)(i * pageStepValue);
child.sizeDelta = new Vector2(panelDimensions.width, panelDimensions.height);
child.anchoredPosition = new Vector2(currentXPosition, 0f);
child.anchorMin = new Vector2(0f, child.anchorMin.y);

View File

@ -48,9 +48,10 @@ namespace UnityEngine.UI.Extensions
[SerializeField]
public int StartingScreen = 1;
[Tooltip("The distance between two pages, by default 3 times the width of the control")]
[Tooltip("The distance between two pages based on page height, by default 3 times the width of the control")]
[SerializeField]
public int PageStep = 0;
[Range(0, 8)]
public float PageStep = 0;
public int CurrentPage
{
@ -71,10 +72,7 @@ namespace UnityEngine.UI.Extensions
}
_screensContainer = _scroll_rect.content;
if (PageStep == 0)
{
PageStep = (int)_scroll_rect.GetComponent<RectTransform>().rect.height * 3;
}
DistributePages();
_lerp = false;
@ -228,15 +226,19 @@ namespace UnityEngine.UI.Extensions
{
float _offset = 0;
float _dimension = 0;
Vector2 panelDimensions = gameObject.GetComponent<RectTransform>().sizeDelta;
Rect panelDimensions = gameObject.GetComponent<RectTransform>().rect;
float currentYPosition = 0;
var pageStepValue = (int)panelDimensions.height * ((PageStep == 0) ? 3 : PageStep);
for (int i = 0; i < _screensContainer.transform.childCount; i++)
{
RectTransform child = _screensContainer.transform.GetChild(i).gameObject.GetComponent<RectTransform>();
currentYPosition = _offset + i * PageStep;
child.sizeDelta = new Vector2(panelDimensions.x, panelDimensions.y);
child.anchoredPosition = new Vector2(0f - panelDimensions.x / 2, currentYPosition + panelDimensions.y / 2);
currentYPosition = _offset + i * pageStepValue;
child.sizeDelta = new Vector2(panelDimensions.width, panelDimensions.height);
child.anchoredPosition = new Vector2(0f, currentYPosition);
child.anchorMin = new Vector2(child.anchorMin.x, 0f);
child.anchorMax = new Vector2(child.anchorMax.x, 0f);
child.pivot = new Vector2(child.pivot.x, 0f);
}
_dimension = currentYPosition + _offset * -1;