parent
68b0445b28
commit
1f16a65f0f
|
@ -66,21 +66,21 @@ namespace UnityEngine.UI.Extensions
|
||||||
(_scroll_rect.velocity.x < startingSpeed && _scroll_rect.velocity.x > -SwipeVelocityThreshold);
|
(_scroll_rect.velocity.x < startingSpeed && _scroll_rect.velocity.x > -SwipeVelocityThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DistributePages()
|
public void DistributePages()
|
||||||
{
|
{
|
||||||
_screens = _screensContainer.childCount;
|
_screens = _screensContainer.childCount;
|
||||||
_scroll_rect.horizontalNormalizedPosition = 0;
|
_scroll_rect.horizontalNormalizedPosition = 0;
|
||||||
|
|
||||||
int _offset = 0;
|
float _offset = 0;
|
||||||
float _dimension = 0;
|
float _dimension = 0;
|
||||||
|
Rect panelDimensions = gameObject.GetComponent<RectTransform>().rect;
|
||||||
float currentXPosition = 0;
|
float currentXPosition = 0;
|
||||||
var pageStepValue = _childSize = (int)panelDimensions.width * ((PageStep == 0) ? 3 : PageStep);
|
var pageStepValue = _childSize = (int)panelDimensions.width * ((PageStep == 0) ? 3 : PageStep);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < _screensContainer.transform.childCount; i++)
|
for (int i = 0; i < _screensContainer.transform.childCount; i++)
|
||||||
{
|
{
|
||||||
RectTransform child = _screensContainer.transform.GetChild(i).gameObject.GetComponent<RectTransform>();
|
RectTransform child = _screensContainer.transform.GetChild(i).gameObject.GetComponent<RectTransform>();
|
||||||
currentXPosition = _offset + (int)(i * pageStepValue);
|
currentXPosition = _offset + i * pageStepValue;
|
||||||
child.sizeDelta = new Vector2(panelDimensions.width, panelDimensions.height);
|
child.sizeDelta = new Vector2(panelDimensions.width, panelDimensions.height);
|
||||||
child.anchoredPosition = new Vector2(currentXPosition, 0f);
|
child.anchoredPosition = new Vector2(currentXPosition, 0f);
|
||||||
child.anchorMin = child.anchorMax = child.pivot = _childAnchorPoint;
|
child.anchorMin = child.anchorMax = child.pivot = _childAnchorPoint;
|
||||||
|
@ -88,7 +88,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
_dimension = currentXPosition + _offset * -1;
|
_dimension = currentXPosition + _offset * -1;
|
||||||
|
|
||||||
_screensContainer.offsetMax = new Vector2(_dimension, 0f);
|
_screensContainer.GetComponent<RectTransform>().offsetMax = new Vector2(_dimension, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
/// *Note, this is an index address (0-x)
|
/// *Note, this is an index address (0-x)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index">Index element of child to remove</param>
|
/// <param name="index">Index element of child to remove</param>
|
||||||
/// <param name="ChildRemoved">>Resulting removed GO</param>
|
/// <param name="ChildRemoved">Resulting removed GO</param>
|
||||||
public void RemoveChild(int index, out GameObject ChildRemoved)
|
public void RemoveChild(int index, out GameObject ChildRemoved)
|
||||||
{
|
{
|
||||||
RemoveChild(index, false, out ChildRemoved);
|
RemoveChild(index, false, out ChildRemoved);
|
||||||
|
@ -158,7 +158,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
SetScrollContainerPosition();
|
SetScrollContainerPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove all children from this ScrollSnap
|
/// Remove all children from this ScrollSnap
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue