ConfigIntegerSlider.cs 760 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using config.ui;
  3. using UnityEngine;
  4. public class ConfigIntegerSlider : MonoBehaviour
  5. {
  6. public void Initialize()
  7. {
  8. this.slider.onGetValue = new Func<int>(this.OnGetValue);
  9. this.slider.onSetValue = new Action<int>(this.OnSetValue);
  10. this.slider.Initialize(this.uiSlider);
  11. }
  12. public void UpdateSlider()
  13. {
  14. this.slider.UpdateSlider();
  15. }
  16. private int OnGetValue()
  17. {
  18. return (this.onGetValue == null) ? 0 : this.onGetValue();
  19. }
  20. private void OnSetValue(int value)
  21. {
  22. if (this.onSetValue != null)
  23. {
  24. this.onSetValue(value);
  25. }
  26. }
  27. public Action<int> onSetValue;
  28. public Func<int> onGetValue;
  29. [ReadOnly]
  30. [SerializeField]
  31. private UISlider uiSlider;
  32. [NonSerialized]
  33. public IntegerSlider slider = new IntegerSlider();
  34. }