NROverlayEditor.cs 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal.Experimental
  10. {
  11. using UnityEditor;
  12. using UnityEngine;
  13. [CustomEditor(typeof(NROverlay))]
  14. public class NROverlayEditor : Editor
  15. {
  16. public override void OnInspectorGUI()
  17. {
  18. NROverlay overlay = (NROverlay)target;
  19. if (overlay == null)
  20. {
  21. return;
  22. }
  23. EditorGUILayout.LabelField("Display Order", EditorStyles.boldLabel);
  24. overlay.compositionDepth = EditorGUILayout.IntField(new GUIContent("Composition Depth", "Depth value used to sort OVROverlays in the scene, smaller value appears in front"), overlay.compositionDepth);
  25. EditorGUILayout.Space();
  26. overlay.ActiveOnStart = EditorGUILayout.Toggle(new GUIContent("ActiveOnStart", "Whether active this overlay when script start"), overlay.ActiveOnStart);
  27. EditorGUILayout.Space();
  28. EditorGUILayout.Separator();
  29. EditorGUILayout.LabelField("Textures", EditorStyles.boldLabel);
  30. #if UNITY_ANDROID
  31. bool lastIsExternalSurface = overlay.isExternalSurface;
  32. overlay.isExternalSurface = EditorGUILayout.Toggle(new GUIContent("Is External Surface", "On Android, retrieve an Android Surface object to render to (e.g., video playback)"), overlay.isExternalSurface);
  33. if (overlay.isExternalSurface)
  34. {
  35. overlay.isDynamic = false;
  36. }
  37. if (lastIsExternalSurface)
  38. {
  39. overlay.externalSurfaceWidth = EditorGUILayout.IntField("External Surface Width", overlay.externalSurfaceWidth);
  40. overlay.externalSurfaceHeight = EditorGUILayout.IntField("External Surface Height", overlay.externalSurfaceHeight);
  41. overlay.isProtectedContent = EditorGUILayout.Toggle(new GUIContent("Is Protected Content", "The external surface has L1 widevine protection."), overlay.isProtectedContent);
  42. }
  43. else
  44. #endif
  45. {
  46. var labelControlRect = EditorGUILayout.GetControlRect();
  47. EditorGUI.LabelField(new Rect(labelControlRect.x, labelControlRect.y, labelControlRect.width / 2, labelControlRect.height), new GUIContent("Texture", "Texture used for the left eye"));
  48. var textureControlRect = EditorGUILayout.GetControlRect(GUILayout.Height(64));
  49. overlay.texture = (Texture)EditorGUI.ObjectField(new Rect(textureControlRect.x, textureControlRect.y, 64, textureControlRect.height), overlay.texture, typeof(Texture), true);
  50. overlay.isDynamic = EditorGUILayout.Toggle(new GUIContent("Dynamic Texture", "This texture will be updated dynamically at runtime (e.g., Video)"), overlay.isDynamic);
  51. }
  52. EditorGUILayout.Separator();
  53. EditorGUILayout.LabelField("Display Mode", EditorStyles.boldLabel);
  54. overlay.layerSide = (LayerSide)EditorGUILayout.EnumPopup(new GUIContent("LayerSide", "Which display this overlay should render to."), overlay.layerSide);
  55. overlay.isScreenSpace = EditorGUILayout.Toggle(new GUIContent("Screen Space", "Whether render this overlay as 0-dof."), overlay.isScreenSpace);
  56. if (overlay.isScreenSpace)
  57. {
  58. overlay.is3DLayer = false;
  59. }
  60. else
  61. {
  62. overlay.is3DLayer = EditorGUILayout.Toggle(new GUIContent("Is 3D rendering layer", "Whether this overlay is 3D rendering layer."), overlay.is3DLayer);
  63. }
  64. EditorGUILayout.Separator();
  65. EditorGUILayout.LabelField("Preview", EditorStyles.boldLabel);
  66. overlay.previewInEditor = EditorGUILayout.Toggle(new GUIContent("Preview in Editor (Experimental)", "Preview the overlay in the editor using a mesh renderer."), overlay.previewInEditor);
  67. if (GUI.changed)
  68. {
  69. EditorUtility.SetDirty(target);
  70. }
  71. }
  72. }
  73. }