Example #1
0
 static void Drawer_FieldOcclusionCulling(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.baseCameraSettings.occlusionCulling, occlusionCullingContent);
 }
Example #2
0
 static void Drawer_Rendering_StopNaNs(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.stopNaNs, Styles.stopNaNs);
 }
Example #3
0
 static void Drawer_FieldExposureTarget(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.exposureTarget, exposureTargetContent);
 }
 static void Drawer_FieldNormalizedViewPort(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.baseCameraSettings.normalizedViewPortRect, viewportContent);
 }
 static void Drawer_Dithering(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.dithering, ditheringContent);
 }
 static void Drawer_FieldVolumeAnchorOverride(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.volumeAnchorOverride, volumeAnchorOverrideContent);
 }
        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;

            Rect perspectiveRect = EditorGUILayout.GetControlRect();

            ProjectionType projectionType;

            EditorGUI.BeginProperty(perspectiveRect, projectionContent, cam.orthographic);
            {
                projectionType = cam.orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;

                EditorGUI.BeginChangeCheck();
                projectionType = (ProjectionType)EditorGUI.EnumPopup(perspectiveRect, projectionContent, projectionType);
                if (EditorGUI.EndChangeCheck())
                {
                    cam.orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
                }
            }
            EditorGUI.EndProperty();

            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_PhysicalCamera(SerializedHDCamera p, Editor owner)
        {
            var cam = p.baseCameraSettings;

            EditorGUILayout.LabelField("Camera Body", EditorStyles.boldLabel);

            using (new EditorGUI.IndentLevelScope())
            {
                EditorGUI.BeginChangeCheck();

                int oldFilmGateIndex = Array.IndexOf(k_ApertureFormatValues, new Vector2((float)Math.Round(cam.sensorSize.vector2Value.x, 3), (float)Math.Round(cam.sensorSize.vector2Value.y, 3)));

                // If it is not one of the preset sizes, set it to custom
                oldFilmGateIndex = (oldFilmGateIndex == -1) ? k_CustomPresetIndex: oldFilmGateIndex;

                // Get the new user selection
                int newFilmGateIndex = EditorGUILayout.Popup(cameraTypeContent, oldFilmGateIndex, k_ApertureFormatNames);

                if (EditorGUI.EndChangeCheck())
                {
                    // Retrieve the previous custom size value, if one exists for this camera
                    object previousCustomValue;
                    s_PerCameraSensorSizeHistory.TryGetValue((Camera)p.serializedObject.targetObject, out previousCustomValue);

                    // When switching from custom to a preset, update the last custom value (to display again, in case the user switches back to custom)
                    if (oldFilmGateIndex == k_CustomPresetIndex)
                    {
                        if (previousCustomValue == null)
                        {
                            s_PerCameraSensorSizeHistory.Add((Camera)p.serializedObject.targetObject, cam.sensorSize.vector2Value);
                        }
                        else
                        {
                            previousCustomValue = cam.sensorSize.vector2Value;
                        }
                    }

                    if (newFilmGateIndex < k_CustomPresetIndex)
                    {
                        cam.sensorSize.vector2Value = k_ApertureFormatValues[newFilmGateIndex];
                    }
                    else
                    {
                        // The user switched back to custom, so display by deafulr the previous custom value
                        if (previousCustomValue != null)
                        {
                            cam.sensorSize.vector2Value = (Vector2)previousCustomValue;
                        }
                        else
                        {
                            cam.sensorSize.vector2Value = new Vector2(36.0f, 24.0f); // this is the value new cameras are created with
                        }
                    }
                }

                EditorGUILayout.PropertyField(cam.sensorSize, sensorSizeContent);
                EditorGUILayout.PropertyField(p.iso, isoContent);

                // Custom layout for shutter speed
                const int k_UnitMenuWidth       = 80;
                const int k_OffsetPerIndent     = 15;
                const int k_LabelFieldSeparator = 2;
                float     indentOffset          = EditorGUI.indentLevel * k_OffsetPerIndent;
                int       oldIndentLevel        = EditorGUI.indentLevel;

                var lineRect  = EditorGUILayout.GetControlRect();
                var labelRect = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth, lineRect.height);
                var fieldRect = new Rect(labelRect.xMax + k_LabelFieldSeparator, lineRect.y, lineRect.width - labelRect.width - k_UnitMenuWidth - k_LabelFieldSeparator * 2, lineRect.height);
                var unitMenu  = new Rect(fieldRect.xMax + k_LabelFieldSeparator, lineRect.y, k_UnitMenuWidth, lineRect.height);

                //We cannot had the shutterSpeedState as this is not a serialized property but a global edition mode.
                //This imply that it will never go bold nor can be reverted in prefab overrides
                EditorGUI.BeginProperty(labelRect, shutterSpeedContent, p.shutterSpeed);
                EditorGUI.LabelField(labelRect, shutterSpeedContent);
                EditorGUI.EndProperty();
                EditorGUI.indentLevel = 0;

                m_ShutterSpeedState.value = (ShutterSpeedUnit)EditorGUI.Popup(unitMenu, (int)m_ShutterSpeedState.value, k_ShutterSpeedUnitNames);

                float previousShutterSpeed = p.shutterSpeed.floatValue;
                if (previousShutterSpeed > 0f && m_ShutterSpeedState.value == ShutterSpeedUnit.OneOverSecond)
                {
                    previousShutterSpeed = 1f / previousShutterSpeed;
                }

                EditorGUI.BeginProperty(fieldRect, shutterSpeedContent, p.shutterSpeed);
                {
                    EditorGUI.BeginChangeCheck();
                    var newShutterSpeed = EditorGUI.FloatField(fieldRect, previousShutterSpeed);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (newShutterSpeed <= 0f)
                        {
                            p.shutterSpeed.floatValue = 0f;
                        }
                        else if (m_ShutterSpeedState.value == ShutterSpeedUnit.OneOverSecond)
                        {
                            p.shutterSpeed.floatValue = 1f / newShutterSpeed;
                        }
                        else
                        {
                            p.shutterSpeed.floatValue = newShutterSpeed;
                        }
                    }
                }
                EditorGUI.EndProperty();
                EditorGUI.indentLevel = oldIndentLevel;

                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         = EditorGUILayout.GetControlRect();
                        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_PhysicalCamera_FocusDistance(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.focusDistance, Styles.focusDistance);
 }
Example #10
0
 static void Drawer_Rendering_Antialiasing_SMAA(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.SMAAQuality, Styles.SMAAQualityPresetContent);
 }
Example #11
0
 static void Drawer_Rendering_Dithering(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.dithering, Styles.dithering);
 }
Example #12
0
 static void Drawer_Rendering_ExposureTarget(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.exposureTarget, Styles.exposureTarget);
 }
Example #13
0
 static void Drawer_Rendering_OcclusionCulling(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.baseCameraSettings.occlusionCulling, Styles.occlusionCulling);
 }
Example #14
0
 static void Drawer_Rendering_CullingMask(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.baseCameraSettings.cullingMask, Styles.cullingMask);
 }
 static void Drawer_SectionXRRendering(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.xrRendering, Styles.xrRenderingContent);
 }
 static void Drawer_PhysicalCamera_CameraBody_ISO(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.iso, Styles.ISO);
 }
Example #17
0
 static void Drawer_FieldVolumeLayerMask(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.volumeLayerMask, volumeLayerMaskContent);
 }
 static void Drawer_Environment_VolumeAnchorOverride(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.volumeAnchorOverride, Styles.volumeAnchorOverride);
 }
Example #19
0
 static void Drawer_FieldCullingMask(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.baseCameraSettings.cullingMask, cullingMaskContent);
 }
 static void Drawer_Environment_ProbeLayerMask(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.probeLayerMask, Styles.probeLayerMask);
 }
Example #21
0
        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 oldFilmGateIndex = Array.IndexOf(k_ApertureFormatValues, new Vector2((float)Math.Round(cam.sensorSize.vector2Value.x, 3), (float)Math.Round(cam.sensorSize.vector2Value.y, 3)));

                // If it is not one of the preset sizes, set it to custom
                oldFilmGateIndex = (oldFilmGateIndex == -1) ? k_CustomPresetIndex: oldFilmGateIndex;

                // Get the new user selection
                int newFilmGateIndex = EditorGUILayout.Popup(cameraTypeContent, oldFilmGateIndex, k_ApertureFormatNames);

                if (EditorGUI.EndChangeCheck())
                {
                    // Retrieve the previous custom size value, if one exists for this camera
                    object previousCustomValue;
                    s_PerCameraSensorSizeHistory.TryGetValue((Camera)p.serializedObject.targetObject, out previousCustomValue);

                    // When switching from custom to a preset, update the last custom value (to display again, in case the user switches back to custom)
                    if (oldFilmGateIndex == k_CustomPresetIndex)
                    {
                        if (previousCustomValue == null)
                        {
                            s_PerCameraSensorSizeHistory.Add((Camera)p.serializedObject.targetObject, cam.sensorSize.vector2Value);
                        }
                        else
                        {
                            previousCustomValue = cam.sensorSize.vector2Value;
                        }
                    }

                    if (newFilmGateIndex < k_CustomPresetIndex)
                    {
                        cam.sensorSize.vector2Value = k_ApertureFormatValues[newFilmGateIndex];
                    }
                    else
                    {
                        // The user switched back to custom, so display by deafulr the previous custom value
                        if (previousCustomValue != null)
                        {
                            cam.sensorSize.vector2Value = (Vector2)previousCustomValue;
                        }
                        else
                        {
                            cam.sensorSize.vector2Value = new Vector2(36.0f, 24.0f); // this is the value new cameras are created with
                        }
                    }
                }

                EditorGUILayout.PropertyField(cam.sensorSize, sensorSizeContent);
                EditorGUILayout.PropertyField(p.iso, isoContent);

                // Custom layout for shutter speed
                const int k_UnitMenuWidth       = 80;
                const int k_OffsetPerIndent     = 15;
                const int k_LabelFieldSeparator = 2;
                const int k_Offset       = 1;
                int       oldIndentLevel = EditorGUI.indentLevel;

                // Don't take into account the indentLevel when rendering the units field
                EditorGUI.indentLevel = 0;

                var lineRect  = EditorGUILayout.GetControlRect();
                var fieldRect = new Rect(k_OffsetPerIndent + k_LabelFieldSeparator + k_Offset, lineRect.y, lineRect.width - k_UnitMenuWidth, lineRect.height);
                var unitMenu  = new Rect(fieldRect.xMax + k_LabelFieldSeparator, lineRect.y, k_UnitMenuWidth - k_LabelFieldSeparator, lineRect.height);

                // We cannot had the shutterSpeedState as this is not a serialized property but a global edition mode.
                // This imply that it will never go bold nor can be reverted in prefab overrides

                m_ShutterSpeedState.value = (ShutterSpeedUnit)EditorGUI.Popup(unitMenu, (int)m_ShutterSpeedState.value, k_ShutterSpeedUnitNames);
                // Reset the indent level
                EditorGUI.indentLevel = oldIndentLevel;

                EditorGUI.BeginProperty(fieldRect, shutterSpeedContent, p.shutterSpeed);
                {
                    // if we we use (1 / second) units, then change the value for the display and then revert it back
                    if (m_ShutterSpeedState.value == ShutterSpeedUnit.OneOverSecond && p.shutterSpeed.floatValue > 0)
                    {
                        p.shutterSpeed.floatValue = 1.0f / p.shutterSpeed.floatValue;
                    }
                    EditorGUI.PropertyField(fieldRect, p.shutterSpeed, shutterSpeedContent);
                    if (m_ShutterSpeedState.value == ShutterSpeedUnit.OneOverSecond && p.shutterSpeed.floatValue > 0)
                    {
                        p.shutterSpeed.floatValue = 1.0f / p.shutterSpeed.floatValue;
                    }
                }
                EditorGUI.EndProperty();

                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;
                            }
                        }

                // Custom layout for aperture
                var rect = EditorGUILayout.BeginHorizontal();
                {
                    // Magic values/offsets to get the UI look consistent
                    const float textRectSize         = 80;
                    const float textRectPaddingRight = 62;
                    const float unitRectPaddingRight = 97;
                    const float sliderPaddingLeft    = 2;
                    const float sliderPaddingRight   = 77;

                    var labelRect = rect;
                    labelRect.width  = EditorGUIUtility.labelWidth;
                    labelRect.height = EditorGUIUtility.singleLineHeight;
                    EditorGUI.LabelField(labelRect, apertureContent);

                    GUI.SetNextControlName("ApertureSlider");
                    var sliderRect = rect;
                    sliderRect.x    += labelRect.width + sliderPaddingLeft;
                    sliderRect.width = rect.width - labelRect.width - sliderPaddingRight;
                    float newVal = GUI.HorizontalSlider(sliderRect, p.aperture.floatValue, HDPhysicalCamera.kMinAperture, HDPhysicalCamera.kMaxAperture);

                    // keep only 2 digits of precision, like the otehr editor fields
                    newVal = Mathf.Floor(100 * newVal) / 100.0f;

                    if (p.aperture.floatValue != newVal)
                    {
                        p.aperture.floatValue = newVal;
                        // Note: We need to move the focus when the slider changes, otherwise the textField will not update
                        GUI.FocusControl("ApertureSlider");
                    }

                    var unitRect = rect;
                    unitRect.x     += rect.width - unitRectPaddingRight;
                    unitRect.width  = textRectSize;
                    unitRect.height = EditorGUIUtility.singleLineHeight;
                    EditorGUI.LabelField(unitRect, "f /", EditorStyles.label);

                    var textRect = rect;
                    textRect.x      = rect.width - textRectPaddingRight;
                    textRect.width  = textRectSize;
                    textRect.height = EditorGUIUtility.singleLineHeight;
                    string newAperture = EditorGUI.TextField(textRect, p.aperture.floatValue.ToString());
                    try
                    {
                        p.aperture.floatValue = Mathf.Clamp(float.Parse(newAperture), HDPhysicalCamera.kMinAperture, HDPhysicalCamera.kMaxAperture);
                    }
                    catch
                    { }
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space(EditorGUIUtility.singleLineHeight);
                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         = EditorGUILayout.GetControlRect();
                        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);
            }
        }
Example #22
0
 static void Drawer_AllowDynamicResolution(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.allowDynamicResolution, allowDynResContent);
     p.baseCameraSettings.allowDynamicResolution.boolValue = p.allowDynamicResolution.boolValue;
 }
Example #23
0
 static void Drawer_FieldDepth(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.baseCameraSettings.depth, depthContent);
 }
Example #24
0
 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);
 }
Example #25
0
 static void Drawer_StopNaNs(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.stopNaNs, stopNaNsContent);
 }
Example #26
0
 static void Drawer_PhysicalCamera_Lens_Shift(SerializedHDCamera p, Editor owner)
 {
     EditorGUILayout.PropertyField(p.baseCameraSettings.lensShift, Styles.shift);
 }