OptionsControlBase.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using SRDebugger.Internal;
  3. using SRF;
  4. using UnityEngine.UI;
  5. namespace SRDebugger.UI.Controls
  6. {
  7. public abstract class OptionsControlBase : SRMonoBehaviourEx
  8. {
  9. public bool SelectionModeEnabled
  10. {
  11. get
  12. {
  13. return this._selectionModeEnabled;
  14. }
  15. set
  16. {
  17. if (value == this._selectionModeEnabled)
  18. {
  19. return;
  20. }
  21. this._selectionModeEnabled = value;
  22. this.SelectionModeToggle.gameObject.SetActive(this._selectionModeEnabled);
  23. if (this.SelectionModeToggle.graphic != null)
  24. {
  25. this.SelectionModeToggle.graphic.CrossFadeAlpha((!this.IsSelected) ? 0f : ((!this._selectionModeEnabled) ? 0.2f : 1f), 0f, true);
  26. }
  27. }
  28. }
  29. public bool IsSelected
  30. {
  31. get
  32. {
  33. return this.SelectionModeToggle.isOn;
  34. }
  35. set
  36. {
  37. this.SelectionModeToggle.isOn = value;
  38. if (this.SelectionModeToggle.graphic != null)
  39. {
  40. this.SelectionModeToggle.graphic.CrossFadeAlpha((!value) ? 0f : ((!this._selectionModeEnabled) ? 0.2f : 1f), 0f, true);
  41. }
  42. }
  43. }
  44. protected override void Awake()
  45. {
  46. base.Awake();
  47. this.IsSelected = false;
  48. this.SelectionModeToggle.gameObject.SetActive(false);
  49. }
  50. protected override void OnEnable()
  51. {
  52. base.OnEnable();
  53. if (this.SelectionModeToggle.graphic != null)
  54. {
  55. this.SelectionModeToggle.graphic.CrossFadeAlpha((!this.IsSelected) ? 0f : ((!this._selectionModeEnabled) ? 0.2f : 1f), 0f, true);
  56. }
  57. }
  58. public virtual void Refresh()
  59. {
  60. }
  61. private bool _selectionModeEnabled;
  62. [RequiredField]
  63. public Toggle SelectionModeToggle;
  64. public OptionDefinition Option;
  65. }
  66. }