NRDisplaySubsystem.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. public class NRDisplaySubsystemDescriptor : IntegratedSubsystemDescriptor<NRDisplaySubsystem>
  12. {
  13. public const string Name = "Subsystem.Display";
  14. public override string id => Name;
  15. }
  16. public class NRDisplaySubsystem : IntegratedSubsystem<NRDisplaySubsystemDescriptor>
  17. {
  18. internal static NativeMultiDisplay NativeMultiDisplay { get; private set; }
  19. public NRDisplaySubsystem(NRDisplaySubsystemDescriptor descriptor) : base(descriptor)
  20. {
  21. NativeMultiDisplay = new NativeMultiDisplay();
  22. #if !UNITY_EDITOR
  23. NativeMultiDisplay.Create();
  24. #endif
  25. }
  26. public override void Start()
  27. {
  28. if (running)
  29. {
  30. return;
  31. }
  32. base.Start();
  33. #if !UNITY_EDITOR
  34. NativeMultiDisplay.Start();
  35. #endif
  36. }
  37. public override void Pause()
  38. {
  39. if (!running)
  40. {
  41. return;
  42. }
  43. base.Pause();
  44. #if !UNITY_EDITOR
  45. NativeMultiDisplay.Pause();
  46. #endif
  47. }
  48. public override void Resume()
  49. {
  50. if (running)
  51. {
  52. return;
  53. }
  54. base.Resume();
  55. #if !UNITY_EDITOR
  56. NativeMultiDisplay.Resume();
  57. #endif
  58. }
  59. public override void Stop()
  60. {
  61. if (!running)
  62. {
  63. return;
  64. }
  65. base.Stop();
  66. #if !UNITY_EDITOR
  67. NativeMultiDisplay.Stop();
  68. NativeMultiDisplay.Destroy();
  69. #endif
  70. }
  71. internal void ListenMainScrResolutionChanged(NRDisplayResolutionCallback callback)
  72. {
  73. #if !UNITY_EDITOR
  74. NativeMultiDisplay.ListenMainScrResolutionChanged(callback);
  75. #endif
  76. }
  77. }
  78. }