From fe8234ba21b5cac716e1c3722d171926c02e942c Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 2 Jul 2020 13:58:40 +0200 Subject: [PATCH 1/3] Shutter speed can now change by dragging over the label --- .../Camera/HDCameraUI.Drawers.cs | 48 ++++++++----------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs index b87477783d0..90826f90da3 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs @@ -359,43 +359,33 @@ static void Drawer_PhysicalCamera(SerializedHDCamera p, Editor owner) const int k_UnitMenuWidth = 80; const int k_OffsetPerIndent = 15; const int k_LabelFieldSeparator = 2; - float indentOffset = EditorGUI.indentLevel * k_OffsetPerIndent; + const int k_Offset = 1; 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(); + + // 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); - - float previousShutterSpeed = p.shutterSpeed.floatValue; - if (previousShutterSpeed > 0f && m_ShutterSpeedState.value == ShutterSpeedUnit.OneOverSecond) - previousShutterSpeed = 1f / previousShutterSpeed; - + // Reset the indent level + EditorGUI.indentLevel = oldIndentLevel; + 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; - } + // if we we use (1 / second) units, then change the value for the disaply 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(); - EditorGUI.indentLevel = oldIndentLevel; using (var horizontal = new EditorGUILayout.HorizontalScope()) using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, gateFitContent, cam.gateFit)) From 1939c9c7005560b600f9c4f5ab561a6fb42358f4 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 2 Jul 2020 14:11:19 +0200 Subject: [PATCH 2/3] Changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index a40eb31ad0d..65daa16a8af 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -862,6 +862,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Renamed the debug name from SSAO to ScreenSpaceAmbientOcclusion (1254974). - Added missing tooltips and improved the UI of the aperture control (case 1254916). - Fixed wrong tooltips in the Dof Volume (case 1256641). +- Shutter speed can now be changed by dragging the mouse over the UI label (case 1245007). ## [7.1.1] - 2019-09-05 From e21898154701bc14069786911fef2c56c874235c Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Thu, 2 Jul 2020 14:49:46 +0200 Subject: [PATCH 3/3] Typo --- .../Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs index 90826f90da3..e78b29b0d24 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Drawers.cs @@ -378,7 +378,7 @@ static void Drawer_PhysicalCamera(SerializedHDCamera p, Editor owner) EditorGUI.BeginProperty(fieldRect, shutterSpeedContent, p.shutterSpeed); { - // if we we use (1 / second) units, then change the value for the disaply and then revert it back + // 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);