Assignment for RMIT Mixed Reality in 2020
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.

79 lines
3.2 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. [CustomEditor(typeof(OVRProjectConfig))]
  6. public class OVRProjectConfigEditor : Editor
  7. {
  8. override public void OnInspectorGUI()
  9. {
  10. OVRProjectConfig projectConfig = (OVRProjectConfig)target;
  11. DrawTargetDeviceInspector(projectConfig);
  12. EditorGUILayout.Space();
  13. DrawProjectConfigInspector(projectConfig);
  14. }
  15. public static void DrawTargetDeviceInspector(OVRProjectConfig projectConfig)
  16. {
  17. bool hasModified = false;
  18. // Target Devices
  19. EditorGUILayout.LabelField("Target Devices", EditorStyles.boldLabel);
  20. foreach (OVRProjectConfig.DeviceType deviceType in System.Enum.GetValues(typeof(OVRProjectConfig.DeviceType)))
  21. {
  22. bool oldSupportsDevice = projectConfig.targetDeviceTypes.Contains(deviceType);
  23. bool newSupportsDevice = oldSupportsDevice;
  24. OVREditorUtil.SetupBoolField(projectConfig, ObjectNames.NicifyVariableName(deviceType.ToString()), ref newSupportsDevice, ref hasModified);
  25. if (newSupportsDevice && !oldSupportsDevice)
  26. {
  27. projectConfig.targetDeviceTypes.Add(deviceType);
  28. }
  29. else if (oldSupportsDevice && !newSupportsDevice)
  30. {
  31. projectConfig.targetDeviceTypes.Remove(deviceType);
  32. }
  33. }
  34. if (hasModified)
  35. {
  36. OVRProjectConfig.CommitProjectConfig(projectConfig);
  37. }
  38. }
  39. public static void DrawProjectConfigInspector(OVRProjectConfig projectConfig)
  40. {
  41. bool hasModified = false;
  42. EditorGUI.BeginDisabledGroup(!projectConfig.targetDeviceTypes.Contains(OVRProjectConfig.DeviceType.Quest));
  43. EditorGUILayout.LabelField("Quest Features", EditorStyles.boldLabel);
  44. // Show overlay support option
  45. OVREditorUtil.SetupBoolField(projectConfig, new GUIContent("Focus Aware",
  46. "If checked, the new overlay will be displayed when the user presses the home button. The game will not be paused, but will now receive InputFocusLost and InputFocusAcquired events."),
  47. ref projectConfig.focusAware, ref hasModified);
  48. // Color Gamut selection
  49. OVREditorUtil.SetupEnumField(projectConfig, new GUIContent(
  50. "Color Gamut",
  51. "The target color gamut when displayed on the Oculus Quest. Quest default is Rec. 2020"),
  52. ref projectConfig.colorGamut, ref hasModified);
  53. // Hand Tracking Support
  54. OVREditorUtil.SetupEnumField(projectConfig, "Hand Tracking Support", ref projectConfig.handTrackingSupport, ref hasModified);
  55. EditorGUI.EndDisabledGroup();
  56. EditorGUILayout.Space();
  57. EditorGUILayout.LabelField("Security", EditorStyles.boldLabel);
  58. OVREditorUtil.SetupBoolField(projectConfig, "Disable Backups", ref projectConfig.disableBackups, ref hasModified);
  59. OVREditorUtil.SetupBoolField(projectConfig, "Enable NSC Configuration", ref projectConfig.enableNSCConfig, ref hasModified);
  60. // apply any pending changes to project config
  61. if (hasModified)
  62. {
  63. OVRProjectConfig.CommitProjectConfig(projectConfig);
  64. }
  65. }
  66. }