Created
March 28, 2015 17:29
-
-
Save marcteys/21cfbb28e9dabc9e24f0 to your computer and use it in GitHub Desktop.
Prevent Click on ScrollRect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
using UnityEngine.EventSystems; | |
using System.Collections; | |
public class PreventClickOnDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler { | |
private ScrollRect sr; | |
private CanvasGroup cg; | |
void Awake() | |
{ | |
sr = this.GetComponent<ScrollRect>(); | |
cg = this.GetComponent<CanvasGroup>(); | |
} | |
public void OnBeginDrag(PointerEventData data) | |
{ | |
cg.interactable = false; | |
} | |
public void OnDrag(PointerEventData data) | |
{ | |
} | |
public void OnEndDrag(PointerEventData data) | |
{ | |
cg.interactable = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment