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.

134 lines
6.3 KiB

  1. /************************************************************************************
  2. Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  3. Licensed under the Oculus Utilities SDK License Version 1.31 (the "License"); you may not use
  4. the Utilities SDK except in compliance with the License, which is provided at the time of installation
  5. or download, or which otherwise accompanies this software in either electronic or hard copy form.
  6. You may obtain a copy of the License at
  7. https://developer.oculus.com/licenses/utilities-1.31
  8. Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
  9. under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  10. ANY KIND, either express or implied. See the License for the specific language governing
  11. permissions and limitations under the License.
  12. ************************************************************************************/
  13. using UnityEngine;
  14. using UnityEditor;
  15. using System.Collections.Generic;
  16. using System.Reflection;
  17. [CustomEditor(typeof(OVRManager))]
  18. public class OVRManagerEditor : Editor
  19. {
  20. override public void OnInspectorGUI()
  21. {
  22. #if UNITY_ANDROID
  23. OVRProjectConfig projectConfig = OVRProjectConfig.GetProjectConfig();
  24. OVRProjectConfigEditor.DrawTargetDeviceInspector(projectConfig);
  25. EditorGUILayout.Space();
  26. #endif
  27. DrawDefaultInspector();
  28. #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_ANDROID
  29. OVRManager manager = (OVRManager)target;
  30. #endif
  31. bool modified = false;
  32. #if UNITY_ANDROID
  33. EditorGUILayout.Space();
  34. OVRProjectConfigEditor.DrawProjectConfigInspector(projectConfig);
  35. EditorGUILayout.Space();
  36. EditorGUILayout.LabelField("Mixed Reality Capture for Quest (experimental)", EditorStyles.boldLabel);
  37. EditorGUI.indentLevel++;
  38. OVREditorUtil.SetupEnumField(target, "ActivationMode", ref manager.mrcActivationMode, ref modified);
  39. EditorGUI.indentLevel--;
  40. #endif
  41. #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
  42. EditorGUILayout.Space();
  43. EditorGUILayout.LabelField("Mixed Reality Capture", EditorStyles.boldLabel);
  44. OVREditorUtil.SetupBoolField(target, "Show Properties", ref manager.expandMixedRealityCapturePropertySheet, ref modified);
  45. if (manager.expandMixedRealityCapturePropertySheet)
  46. {
  47. string[] layerMaskOptions = new string[32];
  48. for (int i=0; i<32; ++i)
  49. {
  50. layerMaskOptions[i] = LayerMask.LayerToName(i);
  51. if (layerMaskOptions[i].Length == 0)
  52. {
  53. layerMaskOptions[i] = "<Layer " + i.ToString() + ">";
  54. }
  55. }
  56. EditorGUI.indentLevel++;
  57. EditorGUILayout.Space();
  58. OVREditorUtil.SetupBoolField(target, "enableMixedReality", ref manager.enableMixedReality, ref modified);
  59. OVREditorUtil.SetupEnumField(target, "compositionMethod", ref manager.compositionMethod, ref modified);
  60. OVREditorUtil.SetupLayerMaskField(target, "extraHiddenLayers", ref manager.extraHiddenLayers, layerMaskOptions, ref modified);
  61. if (manager.compositionMethod == OVRManager.CompositionMethod.External)
  62. {
  63. EditorGUILayout.Space();
  64. EditorGUILayout.LabelField("External Composition", EditorStyles.boldLabel);
  65. EditorGUI.indentLevel++;
  66. OVREditorUtil.SetupColorField(target, "backdropColor (target, Rift)", ref manager.externalCompositionBackdropColorRift, ref modified);
  67. OVREditorUtil.SetupColorField(target, "backdropColor (target, Quest)", ref manager.externalCompositionBackdropColorQuest, ref modified);
  68. }
  69. if (manager.compositionMethod == OVRManager.CompositionMethod.Direct)
  70. {
  71. EditorGUILayout.Space();
  72. EditorGUILayout.LabelField("Direct Composition", EditorStyles.boldLabel);
  73. EditorGUI.indentLevel++;
  74. EditorGUILayout.Space();
  75. EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel);
  76. OVREditorUtil.SetupEnumField(target, "capturingCameraDevice", ref manager.capturingCameraDevice, ref modified);
  77. OVREditorUtil.SetupBoolField(target, "flipCameraFrameHorizontally", ref manager.flipCameraFrameHorizontally, ref modified);
  78. OVREditorUtil.SetupBoolField(target, "flipCameraFrameVertically", ref manager.flipCameraFrameVertically, ref modified);
  79. EditorGUILayout.Space();
  80. EditorGUILayout.LabelField("Chroma Key", EditorStyles.boldLabel);
  81. OVREditorUtil.SetupColorField(target, "chromaKeyColor", ref manager.chromaKeyColor, ref modified);
  82. OVREditorUtil.SetupFloatField(target, "chromaKeySimilarity", ref manager.chromaKeySimilarity, ref modified);
  83. OVREditorUtil.SetupFloatField(target, "chromaKeySmoothRange", ref manager.chromaKeySmoothRange, ref modified);
  84. OVREditorUtil.SetupFloatField(target, "chromaKeySpillRange", ref manager.chromaKeySpillRange, ref modified);
  85. EditorGUILayout.Space();
  86. EditorGUILayout.LabelField("Dynamic Lighting", EditorStyles.boldLabel);
  87. OVREditorUtil.SetupBoolField(target, "useDynamicLighting", ref manager.useDynamicLighting, ref modified);
  88. OVREditorUtil.SetupEnumField(target, "depthQuality", ref manager.depthQuality, ref modified);
  89. OVREditorUtil.SetupFloatField(target, "dynamicLightingSmoothFactor", ref manager.dynamicLightingSmoothFactor, ref modified);
  90. OVREditorUtil.SetupFloatField(target, "dynamicLightingDepthVariationClampingValue", ref manager.dynamicLightingDepthVariationClampingValue, ref modified);
  91. EditorGUILayout.Space();
  92. EditorGUILayout.LabelField("Virtual Green Screen", EditorStyles.boldLabel);
  93. OVREditorUtil.SetupEnumField(target, "virtualGreenScreenType", ref manager.virtualGreenScreenType, ref modified);
  94. OVREditorUtil.SetupFloatField(target, "virtualGreenScreenTopY", ref manager.virtualGreenScreenTopY, ref modified);
  95. OVREditorUtil.SetupFloatField(target, "virtualGreenScreenBottomY", ref manager.virtualGreenScreenBottomY, ref modified);
  96. OVREditorUtil.SetupBoolField(target, "virtualGreenScreenApplyDepthCulling", ref manager.virtualGreenScreenApplyDepthCulling, ref modified);
  97. OVREditorUtil.SetupFloatField(target, "virtualGreenScreenDepthTolerance", ref manager.virtualGreenScreenDepthTolerance, ref modified);
  98. EditorGUILayout.Space();
  99. EditorGUILayout.LabelField("Latency Control", EditorStyles.boldLabel);
  100. OVREditorUtil.SetupFloatField(target, "handPoseStateLatency", ref manager.handPoseStateLatency, ref modified);
  101. EditorGUI.indentLevel--;
  102. }
  103. EditorGUI.indentLevel--;
  104. }
  105. #endif
  106. if (modified)
  107. {
  108. EditorUtility.SetDirty(target);
  109. }
  110. }
  111. }