diff --git a/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/MinMaxSliderPropertyDrawer.cs b/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/MinMaxSliderPropertyDrawer.cs index 9b8ff1f0..dba17183 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/MinMaxSliderPropertyDrawer.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/MinMaxSliderPropertyDrawer.cs @@ -23,35 +23,44 @@ protected override void OnGUI_Internal(Rect rect, SerializedProperty property, G { EditorGUI.BeginProperty(rect, label, property); - float indentLength = NaughtyEditorGUI.GetIndentLength(rect); + bool wideMode = EditorGUIUtility.wideMode; + float labelWidth = EditorGUIUtility.labelWidth + NaughtyEditorGUI.HorizontalSpacing; + float lineHeight = EditorGUIUtility.singleLineHeight; + float indentLength = NaughtyEditorGUI.GetIndentLength(rect); + float xOffset = ((!wideMode)? 0 : labelWidth) - indentLength; + float yOffset = (wideMode)? 0 : lineHeight; float floatFieldWidth = EditorGUIUtility.fieldWidth; - float sliderWidth = rect.width - labelWidth - 2.0f * floatFieldWidth; + float sliderWidth = rect.width - ((!wideMode)? 0 : labelWidth) - 2.0f * floatFieldWidth; float sliderPadding = 5.0f; + + Rect labelRect = new Rect( rect.x, rect.y, labelWidth, - rect.height); + lineHeight); - Rect sliderRect = new Rect( - rect.x + labelWidth + floatFieldWidth + sliderPadding - indentLength, - rect.y, - sliderWidth - 2.0f * sliderPadding + indentLength, - rect.height); Rect minFloatFieldRect = new Rect( - rect.x + labelWidth - indentLength, - rect.y, + rect.x + xOffset, + rect.y + yOffset, floatFieldWidth + indentLength, - rect.height); + lineHeight); + + Rect sliderRect = new Rect( + rect.x + xOffset + floatFieldWidth + sliderPadding, + rect.y + yOffset, + sliderWidth - 2.0f * sliderPadding + indentLength, + lineHeight); Rect maxFloatFieldRect = new Rect( - rect.x + labelWidth + floatFieldWidth + sliderWidth - indentLength, - rect.y, + rect.x + xOffset + floatFieldWidth + sliderWidth, + rect.y + yOffset, floatFieldWidth + indentLength, - rect.height); + lineHeight); + // Draw the label EditorGUI.LabelField(labelRect, label.text); @@ -105,4 +114,4 @@ protected override void OnGUI_Internal(Rect rect, SerializedProperty property, G EditorGUI.EndProperty(); } } -} \ No newline at end of file +}