How do I prevent the Scroll Rect from moving with the mouse say for example I only want a scroll bar to move it and not by dragging across the image or text with the mouse?
2 Answers
SubClass ScrollRect and override it's drag handlers?
Untested but should work:
public class NoDragScrollRect : ScrollRect {
public override void OnBeginDrag(PointerEventData eventData) { }
public override void OnDrag(PointerEventData eventData) { }
public override void OnEndDrag(PointerEventData eventData) { }
}
A simpler solution would be to add a canvas group to the scrollable RectTransform and set it to not block raycast. That way no drag will happen on the RectTransform. This of course only works if you dont need the RectTransform to be interactable at all, otherwise the other answer will do the trick
-
Using a CanvasGroup to !BlocksRaycasts works just fine. Setting a ScrollRect to !Interactable, however, does not. Commented Aug 16, 2015 at 16:14