Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions com.unity.render-pipelines.core/Editor/CoreEditorDrawers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,8 @@ public static class CoreEditorDrawersExtensions
/// <param name="owner">The editor drawing</param>
public static void Draw<TData>(this IEnumerable<CoreEditorDrawer<TData>.IDrawer> drawers, TData data, Editor owner)
{
EditorGUILayout.BeginVertical();
foreach (var drawer in drawers)
drawer.Draw(data, owner);
EditorGUILayout.EndVertical();
}
}
}
2 changes: 1 addition & 1 deletion com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static GUIStyle miniLabelButton
/// <summary>Context Menu button style</summary>
public static GUIStyle contextMenuStyle => m_ContextMenuStyle.Value;

static System.Lazy<GUIStyle> m_AdditionalPropertiesHighlightStyle = new(() => new GUIStyle { normal = { background = Texture2D.whiteTexture } });
static System.Lazy<GUIStyle> m_AdditionalPropertiesHighlightStyle = new(() => new GUIStyle { name = "AdditionalPropertiesHighlightStyle", normal = { background = Texture2D.whiteTexture } });
/// <summary>Style of a additional properties highlighted background.</summary>
public static GUIStyle additionalPropertiesHighlightStyle => m_AdditionalPropertiesHighlightStyle.Value;

Expand Down
27 changes: 26 additions & 1 deletion com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down