| | |
| | | public class ScrollRectGroup : MonoBehaviour, IInitializePotentialDragHandler, IBeginDragHandler, IEndDragHandler, IDragHandler
|
| | | {
|
| | | [SerializeField] ScrollRect[] m_ScrollRects;
|
| | | [SerializeField] Direction m_OnlyDirection;
|
| | | [SerializeField] float m_Offset = 100f;
|
| | |
|
| | | Dictionary<Direction, ScrollRect> scrollRects = new Dictionary<Direction, ScrollRect>();
|
| | |
| | | var position = eventData.position;
|
| | | if (direction == Direction.Both)
|
| | | {
|
| | | var horizontal = Mathf.Abs(position.x - m_StartPosition.x) > m_Offset;
|
| | | var vertical = !horizontal && Mathf.Abs(position.y - m_StartPosition.y) > m_Offset;
|
| | | if (horizontal || vertical)
|
| | | if (m_OnlyDirection == Direction.Both)
|
| | | {
|
| | | var _direction = horizontal ? Direction.Horizontal : Direction.Vertical;
|
| | | if (_direction != direction)
|
| | | var horizontal = Mathf.Abs(position.x - m_StartPosition.x) > m_Offset;
|
| | | var vertical = !horizontal && Mathf.Abs(position.y - m_StartPosition.y) > m_Offset;
|
| | | if (horizontal || vertical)
|
| | | {
|
| | | direction = _direction;
|
| | | foreach (var scrollRect in m_ScrollRects)
|
| | | var _direction = horizontal ? Direction.Horizontal : Direction.Vertical;
|
| | | if (_direction != direction)
|
| | | {
|
| | | scrollRect.OnBeginDrag(eventData);
|
| | | direction = _direction;
|
| | | foreach (var scrollRect in m_ScrollRects)
|
| | | {
|
| | | scrollRect.OnBeginDrag(eventData);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | direction = m_OnlyDirection;
|
| | | }
|
| | | }
|
| | |
|
| | | if (direction != Direction.Both)
|