XRUtils.cs 969 B

1234567891011121314151617181920212223
  1. namespace UnityEngine.Rendering
  2. {
  3. /// <summary>
  4. /// XR Utility class.
  5. /// </summary>
  6. public static class XRUtils
  7. {
  8. /// <summary>
  9. /// Draw the XR occlusion mesh.
  10. /// </summary>
  11. /// <param name="cmd">Command Buffer used to draw the occlusion mesh.</param>
  12. /// <param name="camera">Camera for which the occlusion mesh is rendered.</param>
  13. /// <param name="stereoEnabled">True if stereo rendering is enabled.</param>
  14. public static void DrawOcclusionMesh(CommandBuffer cmd, Camera camera, bool stereoEnabled = true) // Optional stereoEnabled is for SRP-specific stereo logic
  15. {
  16. if ((!XRGraphics.enabled) || (!camera.stereoEnabled) || (!stereoEnabled))
  17. return;
  18. UnityEngine.RectInt normalizedCamViewport = new UnityEngine.RectInt(0, 0, camera.pixelWidth, camera.pixelHeight);
  19. cmd.DrawOcclusionMesh(normalizedCamViewport);
  20. }
  21. }
  22. }