static void Drawer_FieldIso(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.iso, isoContent); }
static void Drawer_FieldNormalizedViewPort(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.normalizedViewPortRect, viewportContent); }
static void Drawer_FieldCullingMask(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.cullingMask, cullingMaskContent); }
static void Drawer_FieldAperture(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.aperture, apertureContent); }
static void Drawer_FieldVolumeLayerMask(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.volumeLayerMask, volumeLayerMaskContent); }
static void Drawer_FieldCullingMask(SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.baseCameraSettings.cullingMask, cullingMaskContent); }
static void Drawer_FieldRenderingPath(SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.passThrough, fullScreenPassthroughContent); using (new EditorGUI.DisabledScope(p.passThrough.boolValue)) EditorGUILayout.PropertyField(p.customRenderingSettings, renderingPathContent); }
static void Drawer_FieldOcclusionCulling(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.occlusionCulling, occlusionCullingContent); }
static void Drawer_Antialiasing(SerializedHDCamera p, Editor owner) { p.antialiasing.intValue = EditorGUILayout.Popup(antialiasingContent, p.antialiasing.intValue, antialiasingModeNames); }
static void Drawer_Dithering(SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.dithering, ditheringContent); }
static void Drawer_FieldDepth(SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.baseCameraSettings.depth, depthContent); }
static void Drawer_PhysicalCamera(SerializedHDCamera p, Editor owner) { var cam = p.baseCameraSettings; EditorGUILayout.LabelField("Camera Body", EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { EditorGUI.BeginChangeCheck(); int filmGateIndex = Array.IndexOf(k_ApertureFormatValues, new Vector2((float)Math.Round(cam.sensorSize.vector2Value.x, 3), (float)Math.Round(cam.sensorSize.vector2Value.y, 3))); if (filmGateIndex == -1) { filmGateIndex = EditorGUILayout.Popup(cameraTypeContent, k_ApertureFormatNames.Length - 1, k_ApertureFormatNames); } else { filmGateIndex = EditorGUILayout.Popup(cameraTypeContent, filmGateIndex, k_ApertureFormatNames); } if (EditorGUI.EndChangeCheck() && filmGateIndex < k_ApertureFormatValues.Length) { cam.sensorSize.vector2Value = k_ApertureFormatValues[filmGateIndex]; } EditorGUILayout.PropertyField(cam.sensorSize, sensorSizeContent); EditorGUILayout.PropertyField(p.iso, isoContent); EditorGUILayout.PropertyField(p.shutterSpeed, shutterSpeedContent); using (var horizontal = new EditorGUILayout.HorizontalScope()) using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, gateFitContent, cam.gateFit)) using (var checkScope = new EditorGUI.ChangeCheckScope()) { int gateValue = (int)(Camera.GateFitMode)EditorGUILayout.EnumPopup(propertyScope.content, (Camera.GateFitMode)cam.gateFit.intValue); if (checkScope.changed) { cam.gateFit.intValue = gateValue; } } } EditorGUILayout.LabelField("Lens", EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { using (var horizontal = new EditorGUILayout.HorizontalScope()) using (new EditorGUI.PropertyScope(horizontal.rect, focalLengthContent, cam.focalLength)) using (var checkScope = new EditorGUI.ChangeCheckScope()) { float sensorLength = cam.fovAxisMode.intValue == 0 ? cam.sensorSize.vector2Value.y : cam.sensorSize.vector2Value.x; float focalLengthVal = s_FovChanged ? Camera.FieldOfViewToFocalLength(s_FovLastValue, sensorLength) : cam.focalLength.floatValue; focalLengthVal = EditorGUILayout.FloatField(focalLengthContent, focalLengthVal); if (checkScope.changed || s_FovChanged) { cam.focalLength.floatValue = focalLengthVal; } } EditorGUILayout.PropertyField(p.aperture, apertureContent); EditorGUILayout.PropertyField(cam.lensShift, lensShiftContent); } EditorGUILayout.LabelField("Aperture Shape", EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(p.bladeCount, bladeCountContent); using (var horizontal = new EditorGUILayout.HorizontalScope()) using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, curvatureContent, p.curvature)) { var v = p.curvature.vector2Value; // The layout system breaks alignment when mixing inspector fields with custom layout'd // fields as soon as a scrollbar is needed in the inspector, so we'll do the layout // manually instead const int kFloatFieldWidth = 50; const int kSeparatorWidth = 5; float indentOffset = EditorGUI.indentLevel * 15f; var lineRect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight); var labelRect = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth - indentOffset, lineRect.height); var floatFieldLeft = new Rect(labelRect.xMax, lineRect.y, kFloatFieldWidth + indentOffset, lineRect.height); var sliderRect = new Rect(floatFieldLeft.xMax + kSeparatorWidth - indentOffset, lineRect.y, lineRect.width - labelRect.width - kFloatFieldWidth * 2 - kSeparatorWidth * 2, lineRect.height); var floatFieldRight = new Rect(sliderRect.xMax + kSeparatorWidth - indentOffset, lineRect.y, kFloatFieldWidth + indentOffset, lineRect.height); EditorGUI.PrefixLabel(labelRect, propertyScope.content); v.x = EditorGUI.FloatField(floatFieldLeft, v.x); EditorGUI.MinMaxSlider(sliderRect, ref v.x, ref v.y, HDPhysicalCamera.kMinAperture, HDPhysicalCamera.kMaxAperture); v.y = EditorGUI.FloatField(floatFieldRight, v.y); p.curvature.vector2Value = v; } EditorGUILayout.PropertyField(p.barrelClipping, barrelClippingContent); EditorGUILayout.PropertyField(p.anamorphism, anamorphismContent); } }
static void Drawer_Projection(SerializedHDCamera p, Editor owner) { // Most of this is replicated from CameraEditor.DrawProjection as we don't want to draw // it the same way it's done in non-SRP cameras. Unfortunately, because a lot of the // code is internal, we have to copy/paste some stuff from the editor code :( var cam = p.baseCameraSettings; var projectionType = cam.orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective; EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = cam.orthographic.hasMultipleDifferentValues; projectionType = (ProjectionType)EditorGUILayout.EnumPopup(projectionContent, projectionType); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { cam.orthographic.boolValue = (projectionType == ProjectionType.Orthographic); } if (cam.orthographic.hasMultipleDifferentValues) { return; } if (projectionType == ProjectionType.Orthographic) { EditorGUILayout.PropertyField(cam.orthographicSize, sizeContent); } else { float fovCurrentValue; bool multipleDifferentFovValues = false; bool isPhysicalCamera = p.projectionMatrixMode.intValue == (int)ProjectionMatrixMode.PhysicalPropertiesBased; var rect = EditorGUILayout.GetControlRect(); var guiContent = EditorGUI.BeginProperty(rect, FOVAxisModeContent, cam.fovAxisMode); EditorGUI.showMixedValue = cam.fovAxisMode.hasMultipleDifferentValues; EditorGUI.BeginChangeCheck(); var fovAxisNewVal = (int)(Camera.FieldOfViewAxis)EditorGUI.EnumPopup(rect, guiContent, (Camera.FieldOfViewAxis)cam.fovAxisMode.intValue); if (EditorGUI.EndChangeCheck()) { cam.fovAxisMode.intValue = fovAxisNewVal; } EditorGUI.EndProperty(); bool fovAxisVertical = cam.fovAxisMode.intValue == 0; if (!fovAxisVertical && !cam.fovAxisMode.hasMultipleDifferentValues) { var targets = p.serializedObject.targetObjects; var camera0 = targets[0] as Camera; float aspectRatio = isPhysicalCamera ? cam.sensorSize.vector2Value.x / cam.sensorSize.vector2Value.y : camera0.aspect; // camera.aspect is not serialized so we have to check all targets. fovCurrentValue = Camera.VerticalToHorizontalFieldOfView(camera0.fieldOfView, aspectRatio); if (targets.Cast <Camera>().Any(camera => camera.fieldOfView != fovCurrentValue)) { multipleDifferentFovValues = true; } } else { fovCurrentValue = cam.verticalFOV.floatValue; multipleDifferentFovValues = cam.fovAxisMode.hasMultipleDifferentValues; } EditorGUI.showMixedValue = multipleDifferentFovValues; var content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), fieldOfViewContent, cam.verticalFOV); EditorGUI.BeginDisabledGroup(p.projectionMatrixMode.hasMultipleDifferentValues || isPhysicalCamera && (cam.sensorSize.hasMultipleDifferentValues || cam.fovAxisMode.hasMultipleDifferentValues)); EditorGUI.BeginChangeCheck(); s_FovLastValue = EditorGUILayout.Slider(content, fovCurrentValue, 0.00001f, 179f); s_FovChanged = EditorGUI.EndChangeCheck(); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); EditorGUI.EndProperty(); EditorGUI.showMixedValue = false; content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), physicalCameraContent, p.projectionMatrixMode); EditorGUI.showMixedValue = p.projectionMatrixMode.hasMultipleDifferentValues; EditorGUI.BeginChangeCheck(); isPhysicalCamera = EditorGUILayout.Toggle(content, isPhysicalCamera); if (EditorGUI.EndChangeCheck()) { p.projectionMatrixMode.intValue = isPhysicalCamera ? (int)ProjectionMatrixMode.PhysicalPropertiesBased : (int)ProjectionMatrixMode.Implicit; } EditorGUILayout.EndHorizontal(); EditorGUI.EndProperty(); EditorGUI.showMixedValue = false; if (s_FovChanged && (!isPhysicalCamera || p.projectionMatrixMode.hasMultipleDifferentValues)) { cam.verticalFOV.floatValue = fovAxisVertical ? s_FovLastValue : Camera.HorizontalToVerticalFieldOfView(s_FovLastValue, (p.serializedObject.targetObjects[0] as Camera).aspect); } EditorGUILayout.Space(); } }
static void Drawer_FieldDepth(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.depth, depthContent); }
static void Drawer_FieldBackgroundColorHDR(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.backgroundColorHDR, backgroundColorContent); }
static void Drawer_FieldRenderingPath(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.renderingPath, renderingPathContent); }
static void Drawer_Projection(HDCameraUI s, SerializedHDCamera p, Editor owner) { p.baseCameraSettings.DrawProjection(); }
static void Drawer_FieldTargetEye(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.IntPopup(p.targetEye, k_TargetEyes, k_TargetEyeValues, targetEyeContent); }
static void Drawer_FieldVR(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.baseCameraSettings.stereoSeparation, stereoSeparationContent); EditorGUILayout.PropertyField(p.baseCameraSettings.stereoConvergence, stereoConvergenceContent); }
static void Drawer_FieldVolumeAnchorOverride(HDCameraUI s, SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.volumeAnchorOverride, volumeAnchorOverrideContent); }
static void Drawer_StopNaNs(SerializedHDCamera p, Editor owner) { EditorGUILayout.PropertyField(p.stopNaNs, stopNaNsContent); }