ProgressScroll.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using SC.InputSystem;
  4. using UnityEngine;
  5. public class ProgressScroll : ProgressEdit
  6. {
  7. public MeshRenderer mr;
  8. private float initValue;
  9. Vector2 initv2;
  10. public override void Start()
  11. {
  12. base.Start();
  13. initv2 = mr.material.GetTextureOffset("_MainTex");
  14. }
  15. public override void OnSCPointerDown(InputDevicePartBase part, SCPointEventData eventData)
  16. {
  17. base.OnSCPointerDown(part, eventData);
  18. initValue = perValue;
  19. }
  20. public override void OnSCPointerUp(InputDevicePartBase part, SCPointEventData eventData)
  21. {
  22. base.OnSCPointerUp(part, eventData);
  23. initv2 = mr.material.GetTextureOffset("_MainTex");
  24. }
  25. public override void OnSCPointerDrag(InputDevicePartBase part, SCPointEventData eventData)
  26. {
  27. base.OnSCPointerDrag(part, eventData);
  28. }
  29. public override void setValue(float f)
  30. {
  31. base.setValue(f);
  32. f = (f - initValue)/2;
  33. float vf = 0;
  34. if((initv2.y - f)>0.85f)
  35. {
  36. vf = 0.85f;
  37. }
  38. else if((initv2.y - f) < 0f)
  39. {
  40. vf = 0f;
  41. }
  42. else
  43. {
  44. vf = initv2.y - f;
  45. }
  46. mr.material.SetTextureOffset("_MainTex", new Vector2(0, vf));
  47. }
  48. }