Merged in fix/scm-programatic (pull request #102)
Programmatic fix for ScrollConflictManager Resolves #353pull/413/head
commit
48fc295a8b
|
@ -18,7 +18,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
public ScrollRect ParentScrollRect;
|
public ScrollRect ParentScrollRect;
|
||||||
|
|
||||||
[Tooltip("The parent ScrollSnap control hosting this Scroll Snap.\nIf left empty, it will use the ScrollSnap of the ParentScrollRect")]
|
[Tooltip("The parent ScrollSnap control hosting this Scroll Snap.\nIf left empty, it will use the ScrollSnap of the ParentScrollRect")]
|
||||||
public ScrollSnapBase ParentScrollSnap;
|
private ScrollSnapBase ParentScrollSnap;
|
||||||
|
|
||||||
private ScrollRect _myScrollRect;
|
private ScrollRect _myScrollRect;
|
||||||
private IBeginDragHandler[] _beginDragHandlers;
|
private IBeginDragHandler[] _beginDragHandlers;
|
||||||
|
@ -30,6 +30,14 @@ namespace UnityEngine.UI.Extensions
|
||||||
private bool scrollOtherHorizontally;
|
private bool scrollOtherHorizontally;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
|
{
|
||||||
|
if (ParentScrollRect)
|
||||||
|
{
|
||||||
|
InitialiseConflictManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitialiseConflictManager()
|
||||||
{
|
{
|
||||||
//Get the current scroll rect so we can disable it if the other one is scrolling
|
//Get the current scroll rect so we can disable it if the other one is scrolling
|
||||||
_myScrollRect = this.GetComponent<ScrollRect>();
|
_myScrollRect = this.GetComponent<ScrollRect>();
|
||||||
|
@ -55,12 +63,27 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
|
{
|
||||||
|
if (ParentScrollRect)
|
||||||
|
{
|
||||||
|
AssignScrollRectHandlers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AssignScrollRectHandlers()
|
||||||
{
|
{
|
||||||
_beginDragHandlers = ParentScrollRect.GetComponents<IBeginDragHandler>();
|
_beginDragHandlers = ParentScrollRect.GetComponents<IBeginDragHandler>();
|
||||||
_dragHandlers = ParentScrollRect.GetComponents<IDragHandler>();
|
_dragHandlers = ParentScrollRect.GetComponents<IDragHandler>();
|
||||||
_endDragHandlers = ParentScrollRect.GetComponents<IEndDragHandler>();
|
_endDragHandlers = ParentScrollRect.GetComponents<IEndDragHandler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetParentScrollRect(ScrollRect parentScrollRect)
|
||||||
|
{
|
||||||
|
ParentScrollRect = parentScrollRect;
|
||||||
|
InitialiseConflictManager();
|
||||||
|
AssignScrollRectHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
#region DragHandler
|
#region DragHandler
|
||||||
|
|
||||||
public void OnBeginDrag(PointerEventData eventData)
|
public void OnBeginDrag(PointerEventData eventData)
|
||||||
|
|
Loading…
Reference in New Issue