SROptions.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.ComponentModel;
  2. using SRF.Service;
  3. using UnityEngine;
  4. using UnityEngine.Scripting;
  5. public delegate void SROptionsPropertyChanged(object sender, string propertyName);
  6. #if !DISABLE_SRDEBUGGER
  7. [Preserve]
  8. #endif
  9. public partial class SROptions : INotifyPropertyChanged
  10. {
  11. private static SROptions _current;
  12. public static SROptions Current
  13. {
  14. get { return _current; }
  15. }
  16. #if !DISABLE_SRDEBUGGER
  17. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
  18. public static void OnStartup()
  19. {
  20. _current = new SROptions(); // Need to reset options here so if we enter play-mode without a domain reload there will be the default set of options.
  21. SRServiceManager.GetService<SRDebugger.Internal.InternalOptionsRegistry>().AddOptionContainer(Current);
  22. }
  23. #endif
  24. public event SROptionsPropertyChanged PropertyChanged;
  25. #if UNITY_EDITOR
  26. [JetBrains.Annotations.NotifyPropertyChangedInvocator]
  27. #endif
  28. public void OnPropertyChanged(string propertyName)
  29. {
  30. if (PropertyChanged != null)
  31. {
  32. PropertyChanged(this, propertyName);
  33. }
  34. if (InterfacePropertyChangedEventHandler != null)
  35. {
  36. InterfacePropertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName));
  37. }
  38. }
  39. private event PropertyChangedEventHandler InterfacePropertyChangedEventHandler;
  40. event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
  41. {
  42. add { InterfacePropertyChangedEventHandler += value; }
  43. remove { InterfacePropertyChangedEventHandler -= value; }
  44. }
  45. }