Updated HSS/VSS OnSelectionChangeEndEvent to also output the landed page number (zero indexed)
Some redundant code clean-up --HG-- branch : develop_5.3release
parent
aadba190c8
commit
df9ea42e02
|
@ -4,7 +4,7 @@ using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace UnityEngine.UI.Extensions
|
namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
public class ScrollSnapBase : MonoBehaviour, IBeginDragHandler, IDragHandler, IPointerDownHandler, IPointerUpHandler
|
public class ScrollSnapBase : MonoBehaviour, IBeginDragHandler, IDragHandler
|
||||||
{
|
{
|
||||||
internal RectTransform _screensContainer;
|
internal RectTransform _screensContainer;
|
||||||
internal bool isVertical;
|
internal bool isVertical;
|
||||||
|
@ -18,7 +18,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
internal ScrollRect _scroll_rect;
|
internal ScrollRect _scroll_rect;
|
||||||
internal Vector3 _lerp_target;
|
internal Vector3 _lerp_target;
|
||||||
internal bool _lerp;
|
internal bool _lerp;
|
||||||
internal bool _pointerDown = false;
|
|
||||||
internal Vector3 _startPosition = new Vector3();
|
internal Vector3 _startPosition = new Vector3();
|
||||||
[Tooltip("The currently active page")]
|
[Tooltip("The currently active page")]
|
||||||
internal int _currentPage;
|
internal int _currentPage;
|
||||||
|
@ -30,7 +29,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SelectionPageChangedEvent : UnityEvent<int> { }
|
public class SelectionPageChangedEvent : UnityEvent<int> { }
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SelectionChangeEndEvent : UnityEvent { }
|
public class SelectionChangeEndEvent : UnityEvent<int> { }
|
||||||
|
|
||||||
[Tooltip("The screen / page to start the control on\n*Note, this is a 0 indexed array")]
|
[Tooltip("The screen / page to start the control on\n*Note, this is a 0 indexed array")]
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
|
@ -316,19 +315,28 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event fires when the user starts to change the page, either via swipe or button
|
||||||
|
/// </summary>
|
||||||
internal void StartScreenChange()
|
internal void StartScreenChange()
|
||||||
{
|
{
|
||||||
OnSelectionChangeStartEvent.Invoke();
|
OnSelectionChangeStartEvent.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event fires when the currently viewed page changes, also updates while the scroll is moving
|
||||||
|
/// </summary>
|
||||||
internal void ScreenChange()
|
internal void ScreenChange()
|
||||||
{
|
{
|
||||||
OnSelectionPageChangedEvent.Invoke(_currentPage);
|
OnSelectionPageChangedEvent.Invoke(_currentPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event fires when control settles on a page, outputs the new page number
|
||||||
|
/// </summary>
|
||||||
internal void EndScreenChange()
|
internal void EndScreenChange()
|
||||||
{
|
{
|
||||||
OnSelectionChangeEndEvent.Invoke();
|
OnSelectionChangeEndEvent.Invoke(_currentPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Interfaces
|
#region Interfaces
|
||||||
|
@ -350,16 +358,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
_lerp = false;
|
_lerp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPointerDown(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
_pointerDown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnPointerUp(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
_pointerDown = false;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue