From d50ae564c454e1792e409dfc85823dc13b5b874a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Mon, 25 Oct 2021 16:07:29 +0200 Subject: [PATCH 1/7] RP Workflows - Adding the capability to revert a single override of a volume component property --- .../Volume/Drawers/FloatParameterDrawer.cs | 16 ++--- .../Runtime/Volume/VolumeComponent.cs | 68 ++++++++++++++++++- .../Runtime/Volume/VolumeManager.cs | 11 +++ .../Runtime/Volume/VolumeParameter.cs | 5 ++ 4 files changed, 90 insertions(+), 10 deletions(-) diff --git a/com.unity.render-pipelines.core/Editor/Volume/Drawers/FloatParameterDrawer.cs b/com.unity.render-pipelines.core/Editor/Volume/Drawers/FloatParameterDrawer.cs index 98f46721884..9a215aebf72 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/Drawers/FloatParameterDrawer.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/Drawers/FloatParameterDrawer.cs @@ -14,8 +14,8 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - float v = EditorGUILayout.FloatField(title, value.floatValue); - value.floatValue = Mathf.Max(v, o.min); + EditorGUILayout.PropertyField(value, title); + value.floatValue = Mathf.Max(value.floatValue, o.min); return true; } } @@ -31,8 +31,8 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - float v = EditorGUILayout.FloatField(title, value.floatValue); - value.floatValue = Mathf.Max(v, o.min); + EditorGUILayout.PropertyField(value, title); + value.floatValue = Mathf.Max(value.floatValue, o.min); return true; } } @@ -48,8 +48,8 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - float v = EditorGUILayout.FloatField(title, value.floatValue); - value.floatValue = Mathf.Min(v, o.max); + EditorGUILayout.PropertyField(value, title); + value.floatValue = Mathf.Min(value.floatValue, o.max); return true; } } @@ -65,8 +65,8 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - float v = EditorGUILayout.FloatField(title, value.floatValue); - value.floatValue = Mathf.Min(v, o.max); + EditorGUILayout.PropertyField(value, title); + value.floatValue = Mathf.Min(value.floatValue, o.max); return true; } } diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index adf1a8eeae3..6d60253fcaa 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Reflection; using System.Linq; +using System.Reflection; +using UnityEditor; namespace UnityEngine.Rendering { @@ -92,7 +93,11 @@ public sealed class VolumeComponentDeprecated : Attribute /// /// [Serializable] +#if UNITY_EDITOR + public class VolumeComponent : ScriptableObject, IApplyRevertPropertyContextMenuItemProvider +#else public class VolumeComponent : ScriptableObject +#endif { /// /// Local attribute for VolumeComponent fields only. @@ -146,7 +151,11 @@ internal static void FindParameters(object o, List parameters, if (field.FieldType.IsSubclassOf(typeof(VolumeParameter))) { if (filter?.Invoke(field) ?? true) - parameters.Add((VolumeParameter)field.GetValue(o)); + { + VolumeParameter volumeParameter = (VolumeParameter)field.GetValue(o); + volumeParameter.name = field.Name; + parameters.Add(volumeParameter); + } } else if (!field.FieldType.IsArray && field.FieldType.IsClass) FindParameters(field.GetValue(o), parameters, filter); @@ -312,5 +321,60 @@ public void Release() parameters[i].Release(); } } + +#if UNITY_EDITOR + internal VolumeParameter GetVolumeParameterByName(string volumeParameterName) + { + for (int i = 0; i < parameters.Count; i++) + { + if (parameters[i] != null && volumeParameterName.Equals(parameters[i].name)) + return parameters[i]; + } + + return null; + } + + public bool TryGetRevertMethodForFieldName(SerializedProperty property, out Action revertMethod) + { + revertMethod = null; + + var volumeParameterName = property.propertyPath.Replace($".{property.name}", string.Empty); + var volumeParameter = GetVolumeParameterByName(volumeParameterName); + + if (volumeParameter == null) + return false; + + var defaultVolumeComponent = VolumeManager.instance.GetDefaultVolumeComponent(property.serializedObject.targetObject.GetType()); + if (defaultVolumeComponent == null) + return false; + + revertMethod = property => + { + var defaultVolumeParameter = defaultVolumeComponent.GetVolumeParameterByName(volumeParameterName); + if (defaultVolumeParameter != null) + { + volumeParameter.SetValue(defaultVolumeParameter); + } + }; + + return true; + } + + public string GetSourceTerm() + { + return "Property"; + } + + public bool TryGetApplyMethodForFieldName(SerializedProperty property, out Action applyMethod) + { + applyMethod = null; + return false; + } + + public string GetSourceName(Component comp) + { + return string.Empty; + } +#endif } } diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs index 81a120e1662..1f9cf320743 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs @@ -59,6 +59,17 @@ public IEnumerable baseComponentTypes // would be error-prone) readonly List m_ComponentsDefaultState; + internal VolumeComponent GetDefaultVolumeComponent(Type volumeComponentType) + { + foreach (VolumeComponent component in m_ComponentsDefaultState) + { + if (component.GetType() == volumeComponentType) + return component; + } + + return null; + } + // Recycled list used for volume traversal readonly List m_TempColliders; diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs index 5e9b4d26fdd..a1084e07e54 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs @@ -46,6 +46,11 @@ public virtual bool overrideState set => m_OverrideState = value; } + /// + /// Name of the parameter + /// + internal string name { get; set; } + internal abstract void Interp(VolumeParameter from, VolumeParameter to, float t); /// From b7bd9811f666bfbe33b1b4707440d5fe5187c3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Mon, 25 Oct 2021 16:10:01 +0200 Subject: [PATCH 2/7] Changelog --- com.unity.render-pipelines.core/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index 3f27285ea34..26c2699a54e 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - Added support for high performant unsafe (uint only) Radix, Merge and Insertion sort algorithms on CoreUnsafeUtils. +- Context menu on Volume Parameters to restore them to their default values. ## [13.1.0] - 2021-09-24 From dea62cb7e0b32f9fb7d470f2d653fb7dbe36697f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Mon, 25 Oct 2021 16:18:43 +0200 Subject: [PATCH 3/7] Improve inheriting interface only on editor --- .../Runtime/Volume/VolumeComponent.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index 6d60253fcaa..b0060b73589 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -93,11 +93,11 @@ public sealed class VolumeComponentDeprecated : Attribute /// /// [Serializable] -#if UNITY_EDITOR - public class VolumeComponent : ScriptableObject, IApplyRevertPropertyContextMenuItemProvider -#else public class VolumeComponent : ScriptableObject +#if UNITY_EDITOR + , IApplyRevertPropertyContextMenuItemProvider #endif + { /// /// Local attribute for VolumeComponent fields only. From 718e4ded41c931b57089862922f4f3974e9325d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Fri, 19 Nov 2021 12:45:10 +0100 Subject: [PATCH 4/7] Fixes for issues found by QA --- .../Volume/Drawers/ColorParameterDrawer.cs | 6 +- .../Volume/Drawers/FloatParameterDrawer.cs | 2 + .../Volume/Drawers/TextureParameterDrawer.cs | 15 ++++- .../Volume/VolumeComponent.EditorOnly.cs | 42 +++++++++++++ .../Volume/VolumeComponent.EditorOnly.cs.meta | 11 ++++ .../Runtime/Volume/VolumeComponent.cs | 62 +------------------ .../Runtime/Volume/VolumeParameter.cs | 5 -- 7 files changed, 73 insertions(+), 70 deletions(-) create mode 100644 com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.EditorOnly.cs create mode 100644 com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.EditorOnly.cs.meta diff --git a/com.unity.render-pipelines.core/Editor/Volume/Drawers/ColorParameterDrawer.cs b/com.unity.render-pipelines.core/Editor/Volume/Drawers/ColorParameterDrawer.cs index 76ab65db3d6..d665e0e5668 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/Drawers/ColorParameterDrawer.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/Drawers/ColorParameterDrawer.cs @@ -14,7 +14,11 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - value.colorValue = EditorGUILayout.ColorField(title, value.colorValue, o.showEyeDropper, o.showAlpha, o.hdr); + + var rect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(rect, title, value); + value.colorValue = EditorGUI.ColorField(rect, title, value.colorValue, o.showEyeDropper, o.showAlpha, o.hdr); + EditorGUI.EndProperty(); return true; } } diff --git a/com.unity.render-pipelines.core/Editor/Volume/Drawers/FloatParameterDrawer.cs b/com.unity.render-pipelines.core/Editor/Volume/Drawers/FloatParameterDrawer.cs index 9a215aebf72..2ec1dcf6afa 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/Drawers/FloatParameterDrawer.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/Drawers/FloatParameterDrawer.cs @@ -132,10 +132,12 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) 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.BeginProperty(lineRect, title, value); EditorGUI.PrefixLabel(labelRect, title); v.x = EditorGUI.FloatField(floatFieldLeft, v.x); EditorGUI.MinMaxSlider(sliderRect, ref v.x, ref v.y, o.min, o.max); v.y = EditorGUI.FloatField(floatFieldRight, v.y); + EditorGUI.EndProperty(); value.vector2Value = v; return true; diff --git a/com.unity.render-pipelines.core/Editor/Volume/Drawers/TextureParameterDrawer.cs b/com.unity.render-pipelines.core/Editor/Volume/Drawers/TextureParameterDrawer.cs index 98cd9957735..fac846219f2 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/Drawers/TextureParameterDrawer.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/Drawers/TextureParameterDrawer.cs @@ -106,7 +106,10 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) if (value.propertyType != SerializedPropertyType.ObjectReference) return false; - TextureParameterHelper.DoObjectField(value, title, typeof(Texture2D), typeof(RenderTexture), validator); + var rect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(rect, title, value); + TextureParameterHelper.DoObjectField(rect, value, title, typeof(Texture2D), typeof(RenderTexture), validator); + EditorGUI.EndProperty(); return true; } } @@ -132,7 +135,10 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) if (value.propertyType != SerializedPropertyType.ObjectReference) return false; - TextureParameterHelper.DoObjectField(value, title, typeof(Texture3D), typeof(RenderTexture), validator); + var rect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(rect, title, value); + TextureParameterHelper.DoObjectField(rect, value, title, typeof(Texture3D), typeof(RenderTexture), validator); + EditorGUI.EndProperty(); return true; } } @@ -157,7 +163,10 @@ static internal bool OnGUI(SerializedProperty value, GUIContent title) if (value.propertyType != SerializedPropertyType.ObjectReference) return false; - TextureParameterHelper.DoObjectField(value, title, typeof(Cubemap), typeof(RenderTexture), validator); + var rect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(rect, title, value); + TextureParameterHelper.DoObjectField(rect, value, title, typeof(Cubemap), typeof(RenderTexture), validator); + EditorGUI.EndProperty(); return true; } diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.EditorOnly.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.EditorOnly.cs new file mode 100644 index 00000000000..a8d9618bdbd --- /dev/null +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.EditorOnly.cs @@ -0,0 +1,42 @@ +#if UNITY_EDITOR + +using System; +using UnityEditor; + +namespace UnityEngine.Rendering +{ + public partial class VolumeComponent : IApplyRevertPropertyContextMenuItemProvider + { + public bool TryGetRevertMethodForFieldName(SerializedProperty property, out Action revertMethod) + { + revertMethod = property => + { + var defaultVolumeComponent = VolumeManager.instance.GetDefaultVolumeComponent(property.serializedObject.targetObject.GetType()); + Undo.RecordObject(property.serializedObject.targetObject, $"Revert property {property.propertyPath} from {property.serializedObject}"); + SerializedObject serializedObject = new SerializedObject(defaultVolumeComponent); + var serializedProperty = serializedObject.FindProperty(property.propertyPath); + property.serializedObject.CopyFromSerializedProperty(serializedProperty); + property.serializedObject.ApplyModifiedProperties(); + }; + + return true; + } + + public string GetSourceTerm() + { + return "Property"; + } + + public bool TryGetApplyMethodForFieldName(SerializedProperty property, out Action applyMethod) + { + applyMethod = null; + return false; + } + + public string GetSourceName(Component comp) + { + return string.Empty; + } + } +} +#endif diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.EditorOnly.cs.meta b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.EditorOnly.cs.meta new file mode 100644 index 00000000000..377bb3c787c --- /dev/null +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.EditorOnly.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c62ee15c68690246a39d8c29726cb19 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index b0060b73589..b58c75787ba 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -93,11 +93,7 @@ public sealed class VolumeComponentDeprecated : Attribute /// /// [Serializable] - public class VolumeComponent : ScriptableObject -#if UNITY_EDITOR - , IApplyRevertPropertyContextMenuItemProvider -#endif - + public partial class VolumeComponent : ScriptableObject { /// /// Local attribute for VolumeComponent fields only. @@ -153,7 +149,6 @@ internal static void FindParameters(object o, List parameters, if (filter?.Invoke(field) ?? true) { VolumeParameter volumeParameter = (VolumeParameter)field.GetValue(o); - volumeParameter.name = field.Name; parameters.Add(volumeParameter); } } @@ -321,60 +316,5 @@ public void Release() parameters[i].Release(); } } - -#if UNITY_EDITOR - internal VolumeParameter GetVolumeParameterByName(string volumeParameterName) - { - for (int i = 0; i < parameters.Count; i++) - { - if (parameters[i] != null && volumeParameterName.Equals(parameters[i].name)) - return parameters[i]; - } - - return null; - } - - public bool TryGetRevertMethodForFieldName(SerializedProperty property, out Action revertMethod) - { - revertMethod = null; - - var volumeParameterName = property.propertyPath.Replace($".{property.name}", string.Empty); - var volumeParameter = GetVolumeParameterByName(volumeParameterName); - - if (volumeParameter == null) - return false; - - var defaultVolumeComponent = VolumeManager.instance.GetDefaultVolumeComponent(property.serializedObject.targetObject.GetType()); - if (defaultVolumeComponent == null) - return false; - - revertMethod = property => - { - var defaultVolumeParameter = defaultVolumeComponent.GetVolumeParameterByName(volumeParameterName); - if (defaultVolumeParameter != null) - { - volumeParameter.SetValue(defaultVolumeParameter); - } - }; - - return true; - } - - public string GetSourceTerm() - { - return "Property"; - } - - public bool TryGetApplyMethodForFieldName(SerializedProperty property, out Action applyMethod) - { - applyMethod = null; - return false; - } - - public string GetSourceName(Component comp) - { - return string.Empty; - } -#endif } } diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs index a1084e07e54..5e9b4d26fdd 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs @@ -46,11 +46,6 @@ public virtual bool overrideState set => m_OverrideState = value; } - /// - /// Name of the parameter - /// - internal string name { get; set; } - internal abstract void Interp(VolumeParameter from, VolumeParameter to, float t); /// From 07d1fe2bc8b8778969d17b1e1d4780dbf89c46d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Fri, 19 Nov 2021 12:51:05 +0100 Subject: [PATCH 5/7] Remove includes --- .../Runtime/Volume/VolumeComponent.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index b58c75787ba..904d87dcc42 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -3,7 +3,6 @@ using System.Collections.ObjectModel; using System.Linq; using System.Reflection; -using UnityEditor; namespace UnityEngine.Rendering { From 69028418907e33caa04578f01d9e0a83ecd76fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Fri, 19 Nov 2021 12:56:45 +0100 Subject: [PATCH 6/7] Fix Gradient Sky > Intensity Mode --- .../Editor/Sky/SkySettingsEditor.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Sky/SkySettingsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Sky/SkySettingsEditor.cs index 02c43ac462d..b74b6a66b78 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Sky/SkySettingsEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Sky/SkySettingsEditor.cs @@ -79,10 +79,13 @@ protected void CommonSkySettingsGUI() { if (scope.displayed) { + var rect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(rect, m_SkyIntensityModeLabel, m_IntensityMode.value); if (m_EnableLuxIntensityMode) - m_IntensityMode.value.intValue = EditorGUILayout.IntPopup(m_SkyIntensityModeLabel, (int)m_IntensityMode.value.intValue, m_IntensityModes, m_IntensityModeValues); + m_IntensityMode.value.intValue = EditorGUI.IntPopup(rect, m_SkyIntensityModeLabel, (int)m_IntensityMode.value.intValue, m_IntensityModes, m_IntensityModeValues); else - m_IntensityMode.value.intValue = EditorGUILayout.IntPopup(m_SkyIntensityModeLabel, (int)m_IntensityMode.value.intValue, m_IntensityModesNoLux, m_IntensityModeValuesNoLux); + m_IntensityMode.value.intValue = EditorGUI.IntPopup(rect, m_SkyIntensityModeLabel, (int)m_IntensityMode.value.intValue, m_IntensityModesNoLux, m_IntensityModeValuesNoLux); + EditorGUI.EndProperty(); } } From 430952f6b8ff516576c62968816988ec1efea895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20V=C3=A1zquez?= Date: Tue, 23 Nov 2021 18:05:01 +0100 Subject: [PATCH 7/7] Last QA pass --- .../Volume/Drawers/IntParameterDrawer.cs | 32 ++++++++++++------- .../Lighting/Shadow/HDShadowSettingsEditor.cs | 11 +++++-- .../Runtime/Lighting/Shadow/ContactShadows.cs | 2 +- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/com.unity.render-pipelines.core/Editor/Volume/Drawers/IntParameterDrawer.cs b/com.unity.render-pipelines.core/Editor/Volume/Drawers/IntParameterDrawer.cs index 41e36c9dd66..fedc72203f3 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/Drawers/IntParameterDrawer.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/Drawers/IntParameterDrawer.cs @@ -15,8 +15,8 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - int v = EditorGUILayout.IntField(title, value.intValue); - value.intValue = Mathf.Max(v, o.min); + EditorGUILayout.PropertyField(value, title); + value.intValue = Mathf.Max(value.intValue, o.min); return true; } } @@ -32,8 +32,8 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - int v = EditorGUILayout.IntField(title, value.intValue); - value.intValue = Mathf.Max(v, o.min); + EditorGUILayout.PropertyField(value, title); + value.intValue = Mathf.Max(value.intValue, o.min); return true; } } @@ -49,8 +49,8 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - int v = EditorGUILayout.IntField(title, value.intValue); - value.intValue = Mathf.Min(v, o.max); + EditorGUILayout.PropertyField(value, title); + value.intValue = Mathf.Min(value.intValue, o.max); return true; } } @@ -66,8 +66,8 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - int v = EditorGUILayout.IntField(title, value.intValue); - value.intValue = Mathf.Min(v, o.max); + EditorGUILayout.PropertyField(value, title); + value.intValue = Mathf.Min(value.intValue, o.max); return true; } } @@ -83,8 +83,11 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - EditorGUILayout.IntSlider(value, o.min, o.max, title); + var lineRect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(lineRect, title, value); + EditorGUI.IntSlider(lineRect, value, o.min, o.max, title); value.intValue = Mathf.Clamp(value.intValue, o.min, o.max); + EditorGUI.EndProperty(); return true; } } @@ -100,8 +103,11 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) return false; var o = parameter.GetObjectRef(); - EditorGUILayout.IntSlider(value, o.min, o.max, title); + var lineRect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(lineRect, title, value); + EditorGUI.IntSlider(lineRect, value, o.min, o.max, title); value.intValue = Mathf.Clamp(value.intValue, o.min, o.max); + EditorGUI.EndProperty(); return true; } } @@ -151,9 +157,11 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) if (value.propertyType != SerializedPropertyType.LayerMask) return false; + var lineRect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(lineRect, title, value); value.intValue = FieldToLayerMask( - EditorGUILayout.MaskField(title, LayerMaskToField(value.intValue), InternalEditorUtility.layers)); - + EditorGUI.MaskField(lineRect, title, LayerMaskToField(value.intValue), InternalEditorUtility.layers)); + EditorGUI.EndProperty(); return true; } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs index d0bb93f0180..166560bdd2d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs @@ -190,7 +190,11 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) float max = o.normalized ? 100f : o.representationDistance; float modifiableValue = value.floatValue * max; EditorGUI.BeginChangeCheck(); - modifiableValue = EditorGUILayout.Slider(title, modifiableValue, 0f, max); + + var lineRect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(lineRect, title, value); + modifiableValue = EditorGUI.Slider(lineRect, title, modifiableValue, 0f, max); + EditorGUI.EndProperty(); if (EditorGUI.EndChangeCheck()) { modifiableValue /= max; @@ -214,7 +218,10 @@ public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) float max = o.normalized ? 100f : o.representationDistance; float modifiableValue = value.floatValue * max; EditorGUI.BeginChangeCheck(); - modifiableValue = EditorGUILayout.Slider(title, modifiableValue, 0f, max); + var lineRect = EditorGUILayout.GetControlRect(); + EditorGUI.BeginProperty(lineRect, title, value); + modifiableValue = EditorGUI.Slider(lineRect, title, modifiableValue, 0f, max); + EditorGUI.EndProperty(); if (EditorGUI.EndChangeCheck()) value.floatValue = Mathf.Clamp01(modifiableValue / max); return true; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.cs index 0ad74d53cb7..8f4562cc0d7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ContactShadows.cs @@ -74,7 +74,7 @@ public int sampleCount } [SerializeField, FormerlySerializedAs("sampleCount")] - private NoInterpClampedIntParameter m_SampleCount = new NoInterpClampedIntParameter(8, 4, 64); + private NoInterpClampedIntParameter m_SampleCount = new NoInterpClampedIntParameter(10, 4, 64); ContactShadows() {