Merged in PixelEnvision/unity-ui-extensions (pull request #3)

ScrollRectMultiTouchFix.cs
pull/413/head
PixelEnvision 2017-04-15 16:19:09 +00:00 committed by Simon Jackson
commit 67bf28cb5a
1 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/// 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;
/// <summary>
/// Begin drag event
/// </summary>
public override void OnBeginDrag (UnityEngine.EventSystems.PointerEventData eventData)
{
pid = eventData.pointerId;
base.OnBeginDrag (eventData);
}
/// <summary>
/// Drag event
/// </summary>
public override void OnDrag (UnityEngine.EventSystems.PointerEventData eventData)
{
if (pid == eventData.pointerId)
base.OnDrag (eventData);
}
/// <summary>
/// End drag event
/// </summary>
public override void OnEndDrag (UnityEngine.EventSystems.PointerEventData eventData)
{
pid = -100;
base.OnEndDrag (eventData);
}
}
}