123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using UnityEngine.EventSystems;
- #if !UNITY_WEBGL
- public class SeekBarCtrl : MonoBehaviour ,IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler, IDragHandler{
- public MediaPlayerCtrl m_srcVideo;
- public Slider m_srcSlider;
- public float m_fDragTime = 0.2f;
- bool m_bActiveDrag = true;
- bool m_bUpdate = true;
- float m_fDeltaTime = 0.0f;
- float m_fLastValue = 0.0f;
- float m_fLastSetValue = 0.0f;
- // Use this for initialization
- void Start () {
-
- }
- // Update is called once per frame
- void Update () {
- if (m_bActiveDrag == false) {
- m_fDeltaTime += Time.deltaTime;
- if (m_fDeltaTime > m_fDragTime) {
- m_bActiveDrag = true;
- m_fDeltaTime = 0.0f;
- //if(m_fLastSetValue != m_fLastValue)
- // m_srcVideo.SetSeekBarValue (m_fLastValue);
- }
- }
- if (m_bUpdate == false)
- return;
-
- if (m_srcVideo != null) {
- if (m_srcSlider != null) {
- m_srcSlider.value = m_srcVideo.GetSeekBarValue();
- }
-
- }
-
- }
- public void OnPointerEnter(PointerEventData eventData)
- {
- Debug.Log("OnPointerEnter:");
- m_bUpdate = false;
- }
- public void OnPointerExit(PointerEventData eventData)
- {
- Debug.Log("OnPointerExit:");
- m_bUpdate = true;
- }
- public void OnPointerDown(PointerEventData eventData)
- {
- }
- public void OnPointerUp(PointerEventData eventData)
- {
-
- m_srcVideo.SetSeekBarValue (m_srcSlider.value);
- }
- public void OnDrag(PointerEventData eventData)
- {
- Debug.Log("OnDrag:"+ eventData);
- if (m_bActiveDrag == false)
- {
- m_fLastValue = m_srcSlider.value;
- return;
- }
- //m_srcVideo.SetSeekBarValue (m_srcSlider.value);
- m_fLastSetValue = m_srcSlider.value;
- m_bActiveDrag = false;
-
- }
- }
- #endif
|