PICOFeatureEditor.cs 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace Unity.XR.OpenXR.Features.PICOSupport
  4. {
  5. [CustomEditor(typeof(PICOFeature))]
  6. internal class PICOFeatureEditor : Editor
  7. {
  8. void OnEnable()
  9. {
  10. }
  11. public override void OnInspectorGUI()
  12. {
  13. PICOFeature picoFeature = (PICOFeature)target;
  14. PICOProjectSetting projectConfig = PICOProjectSetting.GetProjectConfig();
  15. EditorGUIUtility.labelWidth = 180;
  16. //eye tracking
  17. GUIStyle firstLevelStyle = new GUIStyle(GUI.skin.label);
  18. firstLevelStyle.alignment = TextAnchor.UpperLeft;
  19. firstLevelStyle.fontStyle = FontStyle.Bold;
  20. firstLevelStyle.fontSize = 12;
  21. firstLevelStyle.wordWrap = true;
  22. var guiContent = new GUIContent();
  23. guiContent.text = "Eye Tracking";
  24. guiContent.tooltip = "Before calling EyeTracking API, enable this option first, only for Neo3 Pro Eye , PICO 4 Pro device.";
  25. projectConfig.isEyeTracking = EditorGUILayout.Toggle(guiContent, projectConfig.isEyeTracking);
  26. if (projectConfig.isEyeTracking)
  27. {
  28. projectConfig.isEyeTrackingCalibration = EditorGUILayout.Toggle(new GUIContent("Eye Tracking Calibration"), projectConfig.isEyeTrackingCalibration);
  29. EditorGUILayout.BeginVertical("box");
  30. EditorGUILayout.LabelField("Note: Eye Tracking is supported only on Neo 3 Pro Eye , PICO 4 Pro", firstLevelStyle);
  31. EditorGUILayout.EndVertical();
  32. }
  33. projectConfig.isHandTracking = EditorGUILayout.Toggle("Hand Tracking", projectConfig.isHandTracking);
  34. projectConfig.isCameraSubsystem = EditorGUILayout.Toggle("Camera Subsystem", projectConfig.isCameraSubsystem);
  35. picoFeature.isCameraSubsystem = projectConfig.isCameraSubsystem;
  36. var displayFrequencyContent = new GUIContent();
  37. displayFrequencyContent.text = "Display Refresh Rates";
  38. projectConfig.displayFrequency = (SystemDisplayFrequency)EditorGUILayout.EnumPopup(displayFrequencyContent, projectConfig.displayFrequency);
  39. // content protect
  40. projectConfig.useContentProtect = EditorGUILayout.Toggle("Use Content Protect", projectConfig.useContentProtect);
  41. if (projectConfig.useContentProtect)
  42. {
  43. projectConfig.contentProtectFlags = (SecureContentFlag)EditorGUILayout.EnumPopup("Content Protect", projectConfig.contentProtectFlags);
  44. }
  45. //FFR
  46. var foveationEnableContent = new GUIContent();
  47. foveationEnableContent.text = "Foveated Rendering";
  48. projectConfig.foveationEnable = EditorGUILayout.Toggle(foveationEnableContent, projectConfig.foveationEnable);
  49. if (projectConfig.foveationEnable)
  50. {
  51. var foveationContent = new GUIContent();
  52. foveationContent.text = "Foveated Rendering Mode";
  53. projectConfig.foveatedRenderingMode = (FoveationFeature.FoveatedRenderingMode)EditorGUILayout.EnumPopup(foveationContent, projectConfig.foveatedRenderingMode);
  54. var foveationLevel = new GUIContent();
  55. foveationLevel.text = "Foveated Rendering Level";
  56. projectConfig.foveatedRenderingLevel = (FoveationFeature.FoveatedRenderingLevel)EditorGUILayout.EnumPopup(foveationLevel, projectConfig.foveatedRenderingLevel);
  57. if (projectConfig.foveatedRenderingLevel !=FoveationFeature.FoveatedRenderingLevel.Off)
  58. {
  59. var subsampledEnabledContent = new GUIContent();
  60. subsampledEnabledContent.text = "Subsampling";
  61. projectConfig.isSubsampledEnabled = EditorGUILayout.Toggle(subsampledEnabledContent, projectConfig.isSubsampledEnabled);
  62. }
  63. }
  64. GUILayout.BeginHorizontal();
  65. guiContent.text = "System Splash Screen";
  66. guiContent.tooltip = "";
  67. EditorGUILayout.LabelField(guiContent, GUILayout.Width(165));
  68. projectConfig.systemSplashScreen = (Texture2D)EditorGUILayout.ObjectField(projectConfig.systemSplashScreen, typeof(Texture2D), true);
  69. GUILayout.EndHorizontal();
  70. EditorGUILayout.BeginVertical("box");
  71. EditorGUILayout.LabelField("Note: Set the system splash screen picture in PNG format.", firstLevelStyle);
  72. EditorGUILayout.EndVertical();
  73. serializedObject.Update();
  74. if (GUI.changed)
  75. {
  76. EditorUtility.SetDirty(projectConfig);
  77. }
  78. serializedObject.ApplyModifiedProperties();
  79. }
  80. }
  81. }