PICOProjectSetting.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.IO;
  12. using UnityEditor;
  13. using UnityEngine;
  14. namespace Unity.XR.OpenXR.Features.PICOSupport
  15. {
  16. [System.Serializable]
  17. public class PICOProjectSetting: ScriptableObject
  18. {
  19. public bool useContentProtect;
  20. public bool isEyeTracking;
  21. public bool isHandTracking;
  22. public bool isCameraSubsystem;
  23. public bool isEyeTrackingCalibration;
  24. public SystemDisplayFrequency displayFrequency;
  25. public SecureContentFlag contentProtectFlags ;
  26. public bool foveationEnable;
  27. public FoveationFeature.FoveatedRenderingMode foveatedRenderingMode;
  28. public FoveationFeature.FoveatedRenderingLevel foveatedRenderingLevel;
  29. public bool isSubsampledEnabled;
  30. [SerializeField, Tooltip("Set the system splash screen picture in PNG format.")]
  31. public Texture2D systemSplashScreen;
  32. private string splashPath = string.Empty;
  33. public static PICOProjectSetting GetProjectConfig()
  34. {
  35. PICOProjectSetting projectConfig = Resources.Load<PICOProjectSetting>("PICOProjectSetting");
  36. #if UNITY_EDITOR
  37. if (projectConfig == null)
  38. {
  39. projectConfig = CreateInstance<PICOProjectSetting>();
  40. projectConfig.useContentProtect = false;
  41. projectConfig.contentProtectFlags = SecureContentFlag.SECURE_CONTENT_OFF;
  42. projectConfig.isEyeTracking = false;
  43. projectConfig.isCameraSubsystem = false;
  44. projectConfig.isEyeTrackingCalibration = false;
  45. projectConfig.isHandTracking = false;
  46. projectConfig.displayFrequency = SystemDisplayFrequency.Default;
  47. projectConfig.foveationEnable = false;
  48. projectConfig.foveatedRenderingMode = FoveationFeature.FoveatedRenderingMode.FixedFoveatedRendering;
  49. projectConfig.foveatedRenderingLevel = FoveationFeature.FoveatedRenderingLevel.Off;
  50. projectConfig.isSubsampledEnabled = false;
  51. string path = Application.dataPath + "/Resources";
  52. if (!Directory.Exists(path))
  53. {
  54. UnityEditor.AssetDatabase.CreateFolder("Assets", "Resources");
  55. UnityEditor.AssetDatabase.CreateAsset(projectConfig, "Assets/Resources/PICOProjectSetting.asset");
  56. }
  57. else
  58. {
  59. UnityEditor.AssetDatabase.CreateAsset(projectConfig, "Assets/Resources/PICOProjectSetting.asset");
  60. }
  61. }
  62. #endif
  63. return projectConfig;
  64. }
  65. #if UNITY_EDITOR
  66. private void OnValidate()
  67. {
  68. if (systemSplashScreen != null)
  69. {
  70. splashPath = AssetDatabase.GetAssetPath(systemSplashScreen);
  71. if (Path.GetExtension(splashPath).ToLower() != ".png")
  72. {
  73. systemSplashScreen = null;
  74. Debug.LogError("Invalid file format of System Splash Screen, only PNG format is supported. The asset path: " + splashPath);
  75. splashPath = string.Empty;
  76. }
  77. }
  78. }
  79. public string GetSystemSplashScreen(string path)
  80. {
  81. if (systemSplashScreen == null || splashPath == string.Empty)
  82. {
  83. return "0";
  84. }
  85. string targetPath = Path.Combine(path, "src/main/assets/pico_splash.png");
  86. FileUtil.ReplaceFile(splashPath, targetPath);
  87. return "1";
  88. }
  89. #endif
  90. }
  91. }