Author Topic: Smooth UISlider movement with only a few steps?  (Read 3267 times)

mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Smooth UISlider movement with only a few steps?
« on: January 29, 2014, 08:48:58 AM »
I'm liking the new changes in NGUI (3.0.9). Well done!

I have a UISlider in my scene that will only require 6 steps. However, I was hoping when dragged the slider would move freely until released when it would then smoothly snap to the nearest value. Is there an easy way to do this...
Perhaps changing the steps to unlimited on mouse down and back to 6 on mouse up would partly mimic what I want (albeit without smooth snapping)... however, I was hopping someone would have a more elegant solution...

Any thoughts would be greatly appreciated!   

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Smooth UISlider movement with only a few steps?
« Reply #1 on: January 29, 2014, 08:50:38 AM »
Keep the slider free (don't use any steps). When you get OnPress(false), do your rounding logic and set the slider's value to the step-snapped value.

mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Smooth UISlider movement with only a few steps?
« Reply #2 on: January 29, 2014, 08:53:57 AM »
Thanks for the super quick reply... and super clear, simple solution

Goes to show... if you are too close to the problem! Wow I was overthinking it!

:-)