- Home /
How to play scrolling sounds when scrolling through ScrollRect?
Hello,
How do I go about properly playing a scroll sound (like a mouse clicking sound) when scrolling through a ScrollRect ? Basically, I am trying to achieve those little clicking/ticking sounds that play when you scroll through a list of items such as those iphone/facebook lists when choosing a date of birth for a Facebook account...
I tried searching for a video as an example but I didn't have any luck.
I have a ScrollRect and as a child I have a Panel that contains a bunch of buttons in a list (Followed this Unity Live Training turorial http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/creating-scroll-lists-at-run-time)
They scroll nicely and everything but I don't know how to properly implement the scrolling sound.
The ScrollRect has an event OnValueChanged but that just ended up spamming audio. I'm not sure how to go about controlling the ScrollRect onValueChanged...
Any advice, ideas, or direction is greatly appreciated.
Thanks
Answer by AlwaysSunny · Apr 24, 2015 at 05:33 PM
To get clicky sounds with only the mouse scroll wheel, play the sound when scroll input is non-zero.
For sounds that occur regardless of how the scroll rect is manipulated, I guess your best bet is measuring differences in the scrollRect.normalizedPosition. Or you could use OnValueChanged. In either case, accrue some value based on the change, and play a sound + reset this value when some threshold is reached.
It'll be harder to get this working consistently if your content will scale / is dynamic, because all the scrollrect properties operate within a 0..1 range. You'll need to change your click sound threshold value based on the size of the content to get consistent results. Using...... MATH. :U
Your answer
Follow this Question
Related Questions
Make UI ScrollRect end a drag 0 Answers
ScrollRect - Scroll outside the rect!? 0 Answers
Unity UI double Scroll Rect handler? 0 Answers
Buttons in UI Scroll Rect 2 Answers
how to make UI Image inside Scroll Rect (ScrollRect) autoscroll? 1 Answer