Reapplying fixes after having to do a reset, whoops
parent
4e6f14118f
commit
d3fc02c475
|
@ -51,15 +51,11 @@ namespace UnityEngine.UI.Extensions
|
|||
private Vector2 _currentVector;
|
||||
private Quaternion _initRotation;
|
||||
private bool _canDrag = false;
|
||||
[SerializeField]
|
||||
private bool experimental = false;
|
||||
|
||||
private RectTransform m_HandleRect;
|
||||
|
||||
private bool _screenSpaceOverlay;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
m_HandleRect = GetComponent<RectTransform>();
|
||||
_screenSpaceOverlay = GetComponentInParent<Canvas>().rootCanvas.renderMode == RenderMode.ScreenSpaceOverlay;
|
||||
}
|
||||
|
||||
public override void OnPointerUp(PointerEventData eventData)
|
||||
|
@ -83,13 +79,13 @@ namespace UnityEngine.UI.Extensions
|
|||
base.OnPointerDown(eventData);
|
||||
|
||||
_initRotation = transform.rotation;
|
||||
if (experimental)
|
||||
if (_screenSpaceOverlay)
|
||||
{
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(m_HandleRect, eventData.position, eventData.pressEventCamera, out _currentVector);
|
||||
_currentVector = eventData.position - (Vector2)transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentVector = eventData.position - (Vector2)transform.position;
|
||||
_currentVector = eventData.position - (Vector2)Camera.main.WorldToScreenPoint(transform.position);
|
||||
}
|
||||
_initAngle = Mathf.Atan2(_currentVector.y, _currentVector.x) * Mathf.Rad2Deg;
|
||||
}
|
||||
|
@ -102,13 +98,13 @@ namespace UnityEngine.UI.Extensions
|
|||
return;
|
||||
}
|
||||
|
||||
if (experimental)
|
||||
if (_screenSpaceOverlay)
|
||||
{
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(m_HandleRect, eventData.position, eventData.pressEventCamera, out _currentVector);
|
||||
_currentVector = eventData.position - (Vector2)transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentVector = eventData.position - (Vector2)transform.position;
|
||||
_currentVector = eventData.position - (Vector2)Camera.main.WorldToScreenPoint(transform.position);
|
||||
}
|
||||
_currentAngle = Mathf.Atan2(_currentVector.y, _currentVector.x) * Mathf.Rad2Deg;
|
||||
|
||||
|
|
|
@ -94,11 +94,19 @@ namespace UnityEngine.UI.Extensions
|
|||
if (_isInfinate)
|
||||
{
|
||||
//Work out which infinite window we are in
|
||||
float infWindow = (float)value / (float)_screensContainer.childCount;
|
||||
|
||||
if (infWindow < 0)
|
||||
{
|
||||
_infiniteWindow = (int)(Math.Floor(infWindow));
|
||||
}
|
||||
else
|
||||
{
|
||||
_infiniteWindow = value / _screensContainer.childCount;
|
||||
}
|
||||
//Invert the value if negative and differentiate from Window 0
|
||||
_infiniteWindow = value < 0 ? (-_infiniteWindow) + 1 : _infiniteWindow;
|
||||
//Multiplying values by zero doesn't help, so start at Window 1
|
||||
//_infiniteWindow += 1;
|
||||
_infiniteWindow = value < 0 ? (-_infiniteWindow) : _infiniteWindow;
|
||||
|
||||
//Calculate the page within the child count range
|
||||
value = value % _screensContainer.childCount;
|
||||
if (value < 0)
|
||||
|
@ -369,6 +377,7 @@ namespace UnityEngine.UI.Extensions
|
|||
if (_isVertical)
|
||||
{
|
||||
_infiniteOffset = _screensContainer.localPosition.y < 0 ? -_screensContainer.sizeDelta.y * _infiniteWindow : _screensContainer.sizeDelta.y * _infiniteWindow;
|
||||
_infiniteOffset = _infiniteOffset == 0 ? 0 : _infiniteOffset < 0 ? _infiniteOffset - _childSize * _infiniteWindow : _infiniteOffset + _childSize * _infiniteWindow;
|
||||
target.y = _childPos + _scrollStartPosition + _infiniteOffset;
|
||||
}
|
||||
else
|
||||
|
@ -449,8 +458,10 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
Debug.LogError("ScrollRect has to be unidirectional, only use either Horizontal or Vertical on the ScrollRect, NOT both.");
|
||||
}
|
||||
|
||||
var children = gameObject.GetComponent<ScrollRect>().content.childCount;
|
||||
var ScrollRectContent = gameObject.GetComponent<ScrollRect>().content;
|
||||
if (ScrollRectContent != null)
|
||||
{
|
||||
var children = ScrollRectContent.childCount;
|
||||
if (children != 0 || ChildObjects != null)
|
||||
{
|
||||
var childCount = ChildObjects == null || ChildObjects.Length == 0 ? children : ChildObjects.Length;
|
||||
|
@ -464,6 +475,7 @@ namespace UnityEngine.UI.Extensions
|
|||
StartingScreen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (MaskBuffer <= 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue