@@ -18,7 +18,7 @@ public class ScrollConflictManager : MonoBehaviour, IBeginDragHandler, IEndDragH
1818 public ScrollRect ParentScrollRect ;
1919
2020 [ Tooltip ( "The parent ScrollSnap control hosting this Scroll Snap.\n If left empty, it will use the ScrollSnap of the ParentScrollRect" ) ]
21- public ScrollSnapBase ParentScrollSnap ;
21+ private ScrollSnapBase ParentScrollSnap ;
2222
2323 private ScrollRect _myScrollRect ;
2424 private IBeginDragHandler [ ] _beginDragHandlers ;
@@ -30,6 +30,14 @@ public class ScrollConflictManager : MonoBehaviour, IBeginDragHandler, IEndDragH
3030 private bool scrollOtherHorizontally ;
3131
3232 void Awake ( )
33+ {
34+ if ( ParentScrollRect )
35+ {
36+ InitialiseConflictManager ( ) ;
37+ }
38+ }
39+
40+ private void InitialiseConflictManager ( )
3341 {
3442 //Get the current scroll rect so we can disable it if the other one is scrolling
3543 _myScrollRect = this . GetComponent < ScrollRect > ( ) ;
@@ -55,12 +63,27 @@ void Awake()
5563 }
5664
5765 void Start ( )
66+ {
67+ if ( ParentScrollRect )
68+ {
69+ AssignScrollRectHandlers ( ) ;
70+ }
71+ }
72+
73+ private void AssignScrollRectHandlers ( )
5874 {
5975 _beginDragHandlers = ParentScrollRect . GetComponents < IBeginDragHandler > ( ) ;
6076 _dragHandlers = ParentScrollRect . GetComponents < IDragHandler > ( ) ;
6177 _endDragHandlers = ParentScrollRect . GetComponents < IEndDragHandler > ( ) ;
6278 }
6379
80+ public void SetParentScrollRect ( ScrollRect parentScrollRect )
81+ {
82+ ParentScrollRect = parentScrollRect ;
83+ InitialiseConflictManager ( ) ;
84+ AssignScrollRectHandlers ( ) ;
85+ }
86+
6487 #region DragHandler
6588
6689 public void OnBeginDrag ( PointerEventData eventData )
0 commit comments