No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XRSRPSettings.cs 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using System;
  2. using UnityEditor;
  3. using UnityEngine.Experimental.Rendering;
  4. #if ENABLE_VR && ENABLE_VR_MODULE
  5. using UnityEngine.XR;
  6. #endif
  7. namespace UnityEngine.Rendering
  8. {
  9. /// <summary>
  10. /// XRGraphics insulates SRP from API changes across platforms, Editor versions, and as XR transitions into XR SDK
  11. /// </summary>
  12. [Serializable]
  13. public class XRSRPSettings
  14. {
  15. /// <summary>
  16. /// Try enable.
  17. /// </summary>
  18. #if UNITY_EDITOR
  19. // TryEnable gets updated before "play" is pressed- we use this for updating GUI only.
  20. public static bool tryEnable
  21. {
  22. get
  23. {
  24. return false;
  25. }
  26. }
  27. #endif
  28. /// <summary>
  29. /// SRP should use this to safely determine whether XR is enabled at runtime.
  30. /// </summary>
  31. public static bool enabled
  32. {
  33. get
  34. {
  35. #if ENABLE_VR && ENABLE_VR_MODULE
  36. return XRSettings.enabled;
  37. #else
  38. return false;
  39. #endif
  40. }
  41. }
  42. /// <summary>
  43. /// Returns true if the XR device is active.
  44. /// </summary>
  45. public static bool isDeviceActive
  46. {
  47. get
  48. {
  49. #if ENABLE_VR && ENABLE_VR_MODULE
  50. if (enabled)
  51. return XRSettings.isDeviceActive;
  52. #endif
  53. return false;
  54. }
  55. }
  56. /// <summary>
  57. /// Name of the loaded XR device.
  58. /// </summary>
  59. public static string loadedDeviceName
  60. {
  61. get
  62. {
  63. #if ENABLE_VR && ENABLE_VR_MODULE
  64. if (enabled)
  65. return XRSettings.loadedDeviceName;
  66. #endif
  67. return "No XR device loaded";
  68. }
  69. }
  70. /// <summary>
  71. /// List of supported XR devices.
  72. /// </summary>
  73. public static string[] supportedDevices
  74. {
  75. get
  76. {
  77. #if ENABLE_VR && ENABLE_VR_MODULE
  78. if (enabled)
  79. return XRSettings.supportedDevices;
  80. #endif
  81. return new string[1];
  82. }
  83. }
  84. /// <summary>
  85. /// Eye texture descriptor.
  86. /// </summary>
  87. public static RenderTextureDescriptor eyeTextureDesc
  88. {
  89. get
  90. {
  91. #if ENABLE_VR && ENABLE_VR_MODULE
  92. if (enabled)
  93. return XRSettings.eyeTextureDesc;
  94. #endif
  95. return new RenderTextureDescriptor(0, 0);
  96. }
  97. }
  98. /// <summary>
  99. /// Eye texture width.
  100. /// </summary>
  101. public static int eyeTextureWidth
  102. {
  103. get
  104. {
  105. #if ENABLE_VR && ENABLE_VR_MODULE
  106. if (enabled)
  107. return XRSettings.eyeTextureWidth;
  108. #endif
  109. return 0;
  110. }
  111. }
  112. /// <summary>
  113. /// Eye texture height.
  114. /// </summary>
  115. public static int eyeTextureHeight
  116. {
  117. get
  118. {
  119. #if ENABLE_VR && ENABLE_VR_MODULE
  120. if (enabled)
  121. return XRSettings.eyeTextureHeight;
  122. #endif
  123. return 0;
  124. }
  125. }
  126. /// <summary>
  127. /// Occlusion mesh's scaling factor.
  128. /// </summary>
  129. public static float occlusionMeshScale
  130. {
  131. get
  132. {
  133. #if ENABLE_VR && ENABLE_VR_MODULE
  134. if (enabled)
  135. return XRSystem.GetOcclusionMeshScale();
  136. #endif
  137. return 0;
  138. }
  139. set
  140. {
  141. #if ENABLE_VR && ENABLE_VR_MODULE
  142. if (enabled)
  143. XRSystem.SetOcclusionMeshScale(value);
  144. #endif
  145. }
  146. }
  147. /// <summary>
  148. /// Controls XR mirror view blit operation
  149. /// </summary>
  150. public static int mirrorViewMode
  151. {
  152. get
  153. {
  154. #if ENABLE_VR && ENABLE_VR_MODULE
  155. if (enabled)
  156. return XRSystem.GetMirrorViewMode();
  157. #endif
  158. return 0;
  159. }
  160. set
  161. {
  162. #if ENABLE_VR && ENABLE_VR_MODULE
  163. if (enabled)
  164. XRSystem.SetMirrorViewMode(value);
  165. #endif
  166. }
  167. }
  168. }
  169. }