/// Credit BinaryX /// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-1945602 /// Updated by ddreaper - removed dependency on a custom ScrollRect script. Now implements drag interfaces and standard Scroll Rect. using System; using UnityEngine.Events; using UnityEngine.EventSystems; namespace UnityEngine.UI.Extensions { [RequireComponent(typeof(ScrollRect))] [AddComponentMenu("Layout/Extensions/Horizontal Scroll Snap")] public class HorizontalScrollSnap : ScrollSnapBase, IEndDragHandler { // Use this for initialization void Awake() { _scroll_rect = gameObject.GetComponent(); if (_scroll_rect.horizontalScrollbar || _scroll_rect.verticalScrollbar) { Debug.LogWarning("Warning, using scrollbars with the Scroll Snap controls is not advised as it causes unpredictable results"); } //Should this derrive from ScrolRect? isVertical = false; _screensContainer = _scroll_rect.content; DistributePages(); if (NextButton) NextButton.GetComponent