diff --git a/Scripts/Utilities/ScrollRectMultiTouchFix.cs b/Scripts/Utilities/ScrollRectMultiTouchFix.cs new file mode 100644 index 0000000..2ee875a --- /dev/null +++ b/Scripts/Utilities/ScrollRectMultiTouchFix.cs @@ -0,0 +1,45 @@ +/// Credit Erdener Gonenc - @PixelEnvision +/*USAGE: Simply use that instead of the regular ScrollRect */ + +using System; +using UnityEngine.EventSystems; + +namespace UnityEngine.UI.Extensions +{ + [AddComponentMenu ("UI/Extensions/ScrollRectMultiTouchFix")] + public class ScrollRectMultiTouchFix : ScrollRect + { + + private int pid = -100; + + /// + /// Begin drag event + /// + public override void OnBeginDrag (UnityEngine.EventSystems.PointerEventData eventData) + { + pid = eventData.pointerId; + base.OnBeginDrag (eventData); + } + + /// + /// Drag event + /// + public override void OnDrag (UnityEngine.EventSystems.PointerEventData eventData) + { + if (pid == eventData.pointerId) + base.OnDrag (eventData); + } + + /// + /// End drag event + /// + public override void OnEndDrag (UnityEngine.EventSystems.PointerEventData eventData) + { + if (pid == eventData.pointerId) { + pid = -100; + base.OnEndDrag (eventData); + } + } + + } +} \ No newline at end of file