NGUISlider.cs 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using UnityEngine;
  3. namespace wf.ui
  4. {
  5. public abstract class NGUISlider<T> : AbstractSliderWrapper<UISlider>
  6. {
  7. public override UISlider slider
  8. {
  9. get
  10. {
  11. return this.slider_;
  12. }
  13. }
  14. public abstract T sliderValueToSrcValue { get; }
  15. public override void Initialize(UISlider set_slider)
  16. {
  17. base.Initialize(set_slider);
  18. this.slider.onChange.Clear();
  19. this.UpdateSlider();
  20. EventDelegate.Add(this.slider.onChange, new EventDelegate(new EventDelegate.Callback(this.OncChange)));
  21. }
  22. protected void OncChange()
  23. {
  24. this.OnChangeSliderValue();
  25. if (this.onChangeSliderValue != null)
  26. {
  27. this.onChangeSliderValue(this);
  28. }
  29. }
  30. public override void UpdateSlider()
  31. {
  32. if (this.slider == null)
  33. {
  34. return;
  35. }
  36. float srcValueToSliderValue = this.srcValueToSliderValue;
  37. if (!Mathf.Approximately(srcValueToSliderValue, this.slider.value))
  38. {
  39. this.slider.value = srcValueToSliderValue;
  40. }
  41. }
  42. protected T num_ = default(T);
  43. }
  44. }