Service.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. namespace SRDebugger.Internal
  2. {
  3. using Services;
  4. using SRF.Service;
  5. public static class Service
  6. {
  7. private static IConsoleService _consoleService;
  8. private static IDebugPanelService _debugPanelService;
  9. private static IDebugTriggerService _debugTriggerService;
  10. private static IPinnedUIService _pinnedUiService;
  11. private static IDebugCameraService _debugCameraService;
  12. private static IOptionsService _optionsService;
  13. private static IDockConsoleService _dockConsoleService;
  14. #if UNITY_EDITOR && ((!UNITY_2017 && !UNITY_2018 && !UNITY_2019) || UNITY_2019_3_OR_NEWER)
  15. [UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.SubsystemRegistration)]
  16. public static void RuntimeInitialize()
  17. {
  18. // Clear service references at startup in case of "enter play mode without domain reload"
  19. _consoleService = null;
  20. _debugPanelService = null;
  21. _debugTriggerService = null;
  22. _pinnedUiService = null;
  23. _debugCameraService = null;
  24. _optionsService = null;
  25. _dockConsoleService = null;
  26. }
  27. #endif
  28. public static IConsoleService Console
  29. {
  30. get
  31. {
  32. if (_consoleService == null)
  33. {
  34. _consoleService = SRServiceManager.GetService<IConsoleService>();
  35. }
  36. return _consoleService;
  37. }
  38. }
  39. public static IDockConsoleService DockConsole
  40. {
  41. get
  42. {
  43. if (_dockConsoleService == null)
  44. {
  45. _dockConsoleService = SRServiceManager.GetService<IDockConsoleService>();
  46. }
  47. return _dockConsoleService;
  48. }
  49. }
  50. public static IDebugPanelService Panel
  51. {
  52. get
  53. {
  54. if (_debugPanelService == null)
  55. {
  56. _debugPanelService = SRServiceManager.GetService<IDebugPanelService>();
  57. }
  58. return _debugPanelService;
  59. }
  60. }
  61. public static IDebugTriggerService Trigger
  62. {
  63. get
  64. {
  65. if (_debugTriggerService == null)
  66. {
  67. _debugTriggerService = SRServiceManager.GetService<IDebugTriggerService>();
  68. }
  69. return _debugTriggerService;
  70. }
  71. }
  72. public static IPinnedUIService PinnedUI
  73. {
  74. get
  75. {
  76. if (_pinnedUiService == null)
  77. {
  78. _pinnedUiService = SRServiceManager.GetService<IPinnedUIService>();
  79. }
  80. return _pinnedUiService;
  81. }
  82. }
  83. public static IDebugCameraService DebugCamera
  84. {
  85. get
  86. {
  87. if (_debugCameraService == null)
  88. {
  89. _debugCameraService = SRServiceManager.GetService<IDebugCameraService>();
  90. }
  91. return _debugCameraService;
  92. }
  93. }
  94. public static IOptionsService Options
  95. {
  96. get
  97. {
  98. if (_optionsService == null)
  99. {
  100. _optionsService = SRServiceManager.GetService<IOptionsService>();
  101. }
  102. return _optionsService;
  103. }
  104. }
  105. }
  106. }