Author Topic: How to prevent UIScrollView and UITextList from scrolling on mouse drag?  (Read 3638 times)

Zylann

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
UIScrollView and UITextList are scrolling when I drag the mouse on them. I don't want this to happen since my game is for PC and it looks weird.
Is there an option to disable it somewhere?

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
Do you maybe have a UIDragObject component or something on any of the stuff inside your scroll view? Without a collider and/or a UIDragObject you shouldn't even be able to scroll the content I think.

Zylann

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Elements inside my UIScrollView indeed have the UIDragScrollView script, however if I disable it I'm also not able to use the mouse wheel, which I need.

My UITextList cannot have UIDragScrollView, it handles the dragging itself but there are no option to disable it.

Holy Manfred

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 8
  • Posts: 71
    • View Profile
You could just disable the dragging in the OnDrag function of the UIDragScrollView or just use a custom class instead. OnScroll and OnDrag are just regular NGUI events. So technically any script that just does your scrollView.Scroll() in OnScroll would do what you want.

Zylann

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
So at the moment my only solution is to inherit those classes in new ones that just make OnDrag do nothing and change every single prefab/code in my game (there are a lot)...
I think something that simple should be made an option, tbh.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
It's very simple to create your own DragScrollView type class. I do it all the time just so I dont have to extend UIDragScrollView for my 'node' classes.

Zylann

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 17
    • View Profile
Yeah, but when NGUI provides this class, you start using it everywhere but notice it actually works best for mobile games, while allowing this weird scrolling capability on PC without an option to turn it off.
Inheriting is a bad design to solve this. Of course I could have used my own class from the beginning, however I'm not alone on this project and I had to walk for half a day through years of GUI prefabs using it just to replace UIDragScrollViews by UICustomDragScrollViews.