PXR_Settings.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*******************************************************************************
  2. Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
  3. NOTICE:All information contained herein is, and remains the property of
  4. PICO Technology Co., Ltd. The intellectual and technical concepts
  5. contained herein are proprietary to PICO Technology Co., Ltd. and may be
  6. covered by patents, patents in process, and are protected by trade secret or
  7. copyright law. Dissemination of this information or reproduction of this
  8. material is strictly forbidden unless prior written permission is obtained from
  9. PICO Technology Co., Ltd.
  10. *******************************************************************************/
  11. using System;
  12. using UnityEngine;
  13. using UnityEngine.XR.Management;
  14. #if UNITY_EDITOR
  15. using System.IO;
  16. using UnityEditor;
  17. #endif
  18. namespace Unity.XR.PXR
  19. {
  20. [Serializable]
  21. [XRConfigurationData("PICO", "Unity.XR.PXR.Settings")]
  22. public class PXR_Settings : ScriptableObject
  23. {
  24. public enum StereoRenderingModeAndroid
  25. {
  26. MultiPass,
  27. Multiview
  28. }
  29. public enum SystemDisplayFrequency
  30. {
  31. Default,
  32. RefreshRate72,
  33. RefreshRate90,
  34. RefreshRate120,
  35. }
  36. [SerializeField, Tooltip("Set the Stereo Rendering Method")]
  37. public StereoRenderingModeAndroid stereoRenderingModeAndroid;
  38. [SerializeField, Tooltip("Set the system display frequency")]
  39. public SystemDisplayFrequency systemDisplayFrequency;
  40. [SerializeField, Tooltip("if enabled,will always discarding depth and resolving MSAA color to improve performance on tile-based architectures. This only affects Vulkan. Note that this may break user content")]
  41. public bool optimizeBufferDiscards = true;
  42. [SerializeField, Tooltip("Enable Application SpaceWarp")]
  43. public bool enableAppSpaceWarp;
  44. [SerializeField, Tooltip("Set the system splash screen picture in PNG format")]
  45. public Texture2D systemSplashScreen;
  46. private string splashPath = string.Empty;
  47. public ushort GetStereoRenderingMode()
  48. {
  49. return (ushort)stereoRenderingModeAndroid;
  50. }
  51. public ushort GetSystemDisplayFrequency()
  52. {
  53. return (ushort)systemDisplayFrequency;
  54. }
  55. public ushort GetOptimizeBufferDiscards()
  56. {
  57. return optimizeBufferDiscards ? (ushort)1 : (ushort)0;
  58. }
  59. #if UNITY_ANDROID && !UNITY_EDITOR
  60. public static PXR_Settings settings;
  61. public void Awake()
  62. {
  63. settings = this;
  64. }
  65. #elif UNITY_EDITOR
  66. private void OnValidate()
  67. {
  68. if (systemSplashScreen == null)
  69. {
  70. return;
  71. }
  72. splashPath = AssetDatabase.GetAssetPath(systemSplashScreen);
  73. if (!string.Equals(Path.GetExtension(splashPath), ".png", StringComparison.OrdinalIgnoreCase))
  74. {
  75. systemSplashScreen = null;
  76. Debug.LogError("Invalid file format of System Splash Screen, only PNG format is supported. The asset path: " + splashPath);
  77. splashPath = string.Empty;
  78. }
  79. }
  80. public string GetSystemSplashScreen(string path)
  81. {
  82. if (systemSplashScreen == null || splashPath == string.Empty)
  83. {
  84. return "0";
  85. }
  86. string targetPath = Path.Combine(path, "src/main/assets/pico_splash.png");
  87. FileUtil.ReplaceFile(splashPath, targetPath);
  88. return "1";
  89. }
  90. #endif
  91. }
  92. }
粤ICP备19079148号