ScrollViewScroll.cs 885 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using UnityEngine;
  3. public class ScrollViewScroll : MonoBehaviour
  4. {
  5. private void OnPress(bool pressed)
  6. {
  7. this.m_bPress = pressed;
  8. }
  9. public void OnEnable()
  10. {
  11. this.m_bPress = false;
  12. }
  13. public void OnDisable()
  14. {
  15. this.m_bPress = false;
  16. }
  17. private void Update()
  18. {
  19. if (this.m_bPress && 0f <= this.m_ScrollBar.value && this.m_ScrollBar.value <= 1f)
  20. {
  21. if (this.scrollView != null)
  22. {
  23. this.scrollView.Scroll(this.delta * Time.deltaTime);
  24. }
  25. else
  26. {
  27. this.m_ScrollBar.value += this.delta * Time.deltaTime;
  28. }
  29. }
  30. if (this.m_bAlphatSync && this.m_ScrollBar != null && this.m_Sprite != null)
  31. {
  32. this.m_Sprite.alpha = this.m_ScrollBar.alpha;
  33. }
  34. }
  35. public UIScrollView scrollView;
  36. public float delta;
  37. public UIProgressBar m_ScrollBar;
  38. public UIWidget m_Sprite;
  39. public bool m_bAlphatSync = true;
  40. private bool m_bPress;
  41. }