CaptureFromCamera360ODSEditor.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #if UNITY_5_5_OR_NEWER
  2. #define AVPRO_MOVIECAPTURE_UNITYPROFILER_55
  3. #endif
  4. #if UNITY_EDITOR
  5. using UnityEngine;
  6. using UnityEditor;
  7. //-----------------------------------------------------------------------------
  8. // Copyright 2012-2022 RenderHeads Ltd. All rights reserved.
  9. //-----------------------------------------------------------------------------
  10. namespace RenderHeads.Media.AVProMovieCapture.Editor
  11. {
  12. [CanEditMultipleObjects]
  13. [CustomEditor(typeof(CaptureFromCamera360ODS))]
  14. public class CaptureFromCamera360ODSEditor : CaptureBaseEditor
  15. {
  16. //private CaptureFromCamera360ODS _capture;
  17. private SerializedProperty _propCameraSelector;
  18. private SerializedProperty _propCamera;
  19. private SerializedProperty _propRenderResolution;
  20. private SerializedProperty _propRenderSize;
  21. private SerializedProperty _propAntiAliasing;
  22. private SerializedProperty _propRender180Degrees;
  23. private SerializedProperty _propIPD;
  24. private SerializedProperty _propPixelSliceSize;
  25. private SerializedProperty _propPaddingSize;
  26. private SerializedProperty _propCameraClearMode;
  27. private SerializedProperty _propCameraClearColor;
  28. private SerializedProperty _propCameraImageEffects;
  29. protected override void OnEnable()
  30. {
  31. base.OnEnable();
  32. //_capture = (this.target) as CaptureFromCamera360ODS;
  33. _propCameraSelector = serializedObject.AssertFindProperty("_settings.cameraSelector");
  34. _propCamera = serializedObject.AssertFindProperty("_settings.camera");
  35. _propRenderResolution = serializedObject.AssertFindProperty("_renderResolution");
  36. _propRenderSize = serializedObject.AssertFindProperty("_renderSize");
  37. _propAntiAliasing = serializedObject.AssertFindProperty("_renderAntiAliasing");
  38. _propRender180Degrees = serializedObject.AssertFindProperty("_settings.render180Degrees");
  39. _propIPD = serializedObject.AssertFindProperty("_settings.ipd");
  40. _propPixelSliceSize = serializedObject.AssertFindProperty("_settings.pixelSliceSize");
  41. _propPaddingSize = serializedObject.AssertFindProperty("_settings.paddingSize");
  42. _propCameraClearMode = serializedObject.AssertFindProperty("_settings.cameraClearMode");
  43. _propCameraClearColor = serializedObject.AssertFindProperty("_settings.cameraClearColor");
  44. _propCameraImageEffects = serializedObject.AssertFindProperty("_settings.cameraImageEffects");
  45. }
  46. protected void GUI_Camera()
  47. {
  48. EditorGUILayout.PropertyField(_propCameraSelector);
  49. if (null == _propCameraSelector.objectReferenceValue)
  50. {
  51. EditorGUILayout.PropertyField(_propCamera);
  52. }
  53. EditorUtils.EnumAsDropdown("Resolution", _propRenderResolution, CaptureBaseEditor.ResolutionStrings);
  54. if (_propRenderResolution.enumValueIndex == (int)CaptureBase.Resolution.Custom)
  55. {
  56. EditorGUILayout.PropertyField(_propRenderSize, new GUIContent("Size"));
  57. _propRenderSize.vector2Value = new Vector2(Mathf.Clamp((int)_propRenderSize.vector2Value.x, 1, NativePlugin.MaxRenderWidth), Mathf.Clamp((int)_propRenderSize.vector2Value.y, 1, NativePlugin.MaxRenderHeight));
  58. }
  59. {
  60. string currentAA = "None";
  61. if (QualitySettings.antiAliasing > 1)
  62. {
  63. currentAA = QualitySettings.antiAliasing.ToString() + "x";
  64. }
  65. EditorUtils.IntAsDropdown("Anti-aliasing", _propAntiAliasing, new string[] { "Current (" + currentAA + ")", "None", "2x", "4x", "8x" }, new int[] { -1, 1, 2, 4, 8 });
  66. }
  67. EditorGUILayout.Space();
  68. EditorGUILayout.PropertyField(_propRender180Degrees);
  69. EditorGUILayout.PropertyField(_propIPD, new GUIContent("Interpupillary distance"));
  70. EditorGUILayout.PropertyField(_propPixelSliceSize);
  71. EditorGUILayout.PropertyField(_propPaddingSize);
  72. EditorGUILayout.PropertyField(_propCameraClearMode);
  73. EditorGUILayout.PropertyField(_propCameraClearColor);
  74. EditorGUILayout.PropertyField(_propCameraImageEffects, true);
  75. }
  76. protected override void GUI_User()
  77. {
  78. if (_baseCapture != null && !_baseCapture.IsCapturing())
  79. {
  80. serializedObject.Update();
  81. bool boolTrue = true;
  82. EditorUtils.DrawSection("Capture from Camera 360 + ODS", ref boolTrue, GUI_Camera);
  83. #if AVPRO_MOVIECAPTURE_UNITYPROFILER_55
  84. // This component makes the profiler use a TON of memory, so warn the user to disable it
  85. if (UnityEngine.Profiling.Profiler.enabled)
  86. {
  87. ShowNoticeBox(MessageType.Warning, "Having the Unity profiler enabled while using the CaptureFromCamera360ODS component is not recommended.\n\nToo many samples are generated which can make the system run out of memory\n\nDisable the profiler, close the window and remove the tab. A Unity restart may be required after disabling the profiler recording.");
  88. }
  89. #endif
  90. if (serializedObject.ApplyModifiedProperties())
  91. {
  92. EditorUtility.SetDirty(target);
  93. }
  94. }
  95. }
  96. }
  97. }
  98. #endif