diff --git a/com.unity.render-pipelines.core/Editor/CoreEditorDrawers.cs b/com.unity.render-pipelines.core/Editor/CoreEditorDrawers.cs index 0ec5f8b9a10..57bbbe3c4ad 100644 --- a/com.unity.render-pipelines.core/Editor/CoreEditorDrawers.cs +++ b/com.unity.render-pipelines.core/Editor/CoreEditorDrawers.cs @@ -820,10 +820,8 @@ public static class CoreEditorDrawersExtensions /// The editor drawing public static void Draw(this IEnumerable.IDrawer> drawers, TData data, Editor owner) { - EditorGUILayout.BeginVertical(); foreach (var drawer in drawers) drawer.Draw(data, owner); - EditorGUILayout.EndVertical(); } } } diff --git a/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs b/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs index 0641cc62b3a..ddc70b0c458 100644 --- a/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs +++ b/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs @@ -69,7 +69,7 @@ public static GUIStyle miniLabelButton /// Context Menu button style public static GUIStyle contextMenuStyle => m_ContextMenuStyle.Value; - static System.Lazy m_AdditionalPropertiesHighlightStyle = new(() => new GUIStyle { normal = { background = Texture2D.whiteTexture } }); + static System.Lazy m_AdditionalPropertiesHighlightStyle = new(() => new GUIStyle { name = "AdditionalPropertiesHighlightStyle", normal = { background = Texture2D.whiteTexture } }); /// Style of a additional properties highlighted background. public static GUIStyle additionalPropertiesHighlightStyle => m_AdditionalPropertiesHighlightStyle.Value; diff --git a/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs b/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs index d5732577c63..d4f59e8f815 100644 --- a/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs +++ b/com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs @@ -1132,17 +1132,42 @@ internal static void TryToFixFilterMode(float pixelsPerPoint, Texture2D icon) #endregion + static int s_OldIndentLevel; + static float s_OldLabelWidth = EditorGUIUtility.labelWidth; + internal static void BeginAdditionalPropertiesHighlight(AnimFloat animation) { + // Remove the indentation and fake it using the padding of the VerticalLayout + // If we relay on the indentation the following case will happen: + // - the indentation (15) + // - The minimum margin of any of the siblings of the vertical layout (for instance 3) + // - The margin of the internal elements (for instance 3 if we are drawing any textfield) + // Ending up in a total "left offset" of 21, while the previous properties had an offset of 18 + // Ending in a 3px offset for the additional properties, making them unaligned with non additional properties :( + + // Backup the previous values + s_OldIndentLevel = EditorGUI.indentLevel; + s_OldLabelWidth = EditorGUIUtility.labelWidth; + var oldColor = GUI.color; GUI.color = Color.Lerp(CoreEditorStyles.backgroundColor, CoreEditorStyles.backgroundHighlightColor, animation.value); - EditorGUILayout.BeginVertical(CoreEditorStyles.additionalPropertiesHighlightStyle); + + // Change the indent level and the label width + EditorGUI.indentLevel = 0; + int leftPadding = s_OldIndentLevel * 15; // Indent level from EditorGUI.kIndentPerLevel + EditorGUIUtility.labelWidth -= leftPadding; + + EditorGUILayout.BeginVertical(new GUIStyle(CoreEditorStyles.additionalPropertiesHighlightStyle) { padding = new RectOffset(leftPadding, 0, 0, 0) }); GUI.color = oldColor; } internal static void EndAdditionalPropertiesHighlight() { EditorGUILayout.EndVertical(); + + // Restore values + EditorGUI.indentLevel = s_OldIndentLevel; + EditorGUIUtility.labelWidth = s_OldLabelWidth; } } } diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs index 2b0539cd852..d60c5b1ee6b 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs @@ -335,12 +335,9 @@ public virtual void OnDisable() internal void OnInternalInspectorGUI() { serializedObject.Update(); - using (new EditorGUILayout.VerticalScope()) - { - TopRowFields(); - OnInspectorGUI(); - EditorGUILayout.Space(); - } + TopRowFields(); + OnInspectorGUI(); + EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); } @@ -724,13 +721,9 @@ void Init(SerializedDataParameter property, GUIContent label, VolumeComponentEdi { editor.HandleDecorators(property, label); - int relativeIndentation = editor.HandleRelativeIndentation(property); - if (relativeIndentation != 0) - indentScope = new IndentLevelScope(relativeIndentation * 15); - if (!haveCustomOverrideCheckbox) { - EditorGUILayout.BeginHorizontal(); + EditorGUILayout.BeginHorizontal(new GUIStyle() { padding = new RectOffset(editor.HandleRelativeIndentation(property) * 15, 0, 0, 0)}); editor.DrawOverrideCheckbox(property); disabledScope = new EditorGUI.DisabledScope(!property.overrideState.boolValue); diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightEditor.cs index 815e36753cb..3191e6f93fc 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightEditor.cs @@ -79,8 +79,7 @@ public override void OnInspectorGUI() ApplyAdditionalComponentsVisibility(true); EditorGUI.BeginChangeCheck(); - using (new EditorGUILayout.VerticalScope()) - HDLightUI.Inspector.Draw(m_SerializedHDLight, this); + HDLightUI.Inspector.Draw(m_SerializedHDLight, this); if (EditorGUI.EndChangeCheck()) { m_SerializedHDLight.Apply();