- Home /
Scrub control for a video player
I've a video playing on a RenderTexture and a Slider on a canvas connected to it and should controlled the video time (like the usual slider on any video player.) My problem is that I want the handle of that slider to move across the slider area in respect to the current video time AND to be able to manually grab that handle and slide it. I mange to get both thing working but not at the same time. The former I achieved by simply write mySlider.value = videoPlayer.frame/videoPlayer.frameRate;
inside the Update()
method and the latter by using OnDrag()
Event... but the OnDrag()
has no affect when I set the slider value through the Update()
. (It work just fine when I delete that line from Update()
) Any suggestions?
Answer by IdanBar · Nov 29, 2018 at 08:42 AM
Try to use a boolean that checks if the user is dragging the slider. Then set it to true when the user holds the slider, and false when it releases it. Inside the Update()
method, you will need to update the value of the slider only if this boolen is set to false (only if the user isn't dragging the slider).
worked like a charm! i feel so dumb! All i added is a new Event OnDragBegin
that set that bool to true
and an Event OnDragEnd
that set it back to false
. Thank you!!!