Perfromance tweaks for H & V scroll snaps.
Updated create option Matched Size options from HSS update in to VSS --HG-- branch : develop_5.3pull/413/head
parent
cb535507a4
commit
2de76cf7a3
|
@ -322,7 +322,7 @@ namespace UnityEditor.UI
|
|||
rectTransformPage01.anchoredPosition = new Vector2(-rectTransformPage01.sizeDelta.x / 2, rectTransformPage01.sizeDelta.y / 2);
|
||||
//rectTransformPage01.anchoredPosition = Vector2.zero;
|
||||
//rectTransformPage01.sizeDelta = Vector2.zero;
|
||||
rectTransformPage01.pivot = new Vector2(0f, 0.5f);
|
||||
rectTransformPage01.pivot = new Vector2(0.5f, 0f);
|
||||
|
||||
//Setup Text on Page01
|
||||
Text text = childText.AddComponent<Text>();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue