Skip to content

Commit dd7ac88

Browse files
committed
Fixed the slider to the bottom so it doesn't clip.
1 parent 4982f58 commit dd7ac88

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Editor/Attributes/SlideDrawer.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ static SlideDrawer()
1616

1717
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
1818
{
19-
SlideAttribute attr = (SlideAttribute)attribute;
19+
// Lock the position to the bottom
20+
position.y = position.y + position.height - EditorGUIUtility.singleLineHeight;
2021

22+
SlideAttribute attr = (SlideAttribute)attribute;
2123

2224
// Draw the left and right
2325
if (attr.LeftLabel != null)
@@ -34,20 +36,19 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
3436
EditorGUI.LabelField(new Rect(position.x + EditorGUIUtility.labelWidth, position.y + miniLabelVerticalOffset, position.width - EditorGUIUtility.labelWidth + padding, position.height), attr.RightLabel, miniLabelStyle);
3537
}
3638

37-
Rect sliderBox = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
38-
3939
// Draw the slider
40+
Rect sliderPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
4041
switch (property.propertyType)
4142
{
4243
case SerializedPropertyType.Float:
43-
EditorGUI.Slider(sliderBox, property, attr.Min, attr.Max, label);
44+
EditorGUI.Slider(sliderPosition, property, attr.Min, attr.Max, label);
4445
break;
4546
case SerializedPropertyType.Integer:
46-
EditorGUI.IntSlider(sliderBox, property, (int) attr.Min, (int) attr.Max, label);
47+
EditorGUI.IntSlider(sliderPosition, property, (int) attr.Min, (int) attr.Max, label);
4748
break;
4849
case SerializedPropertyType.Vector2:
4950
case SerializedPropertyType.Vector2Int:
50-
MinMaxSlider(sliderBox, property, attr.Min, attr.Max, label);
51+
MinMaxSlider(sliderPosition, property, attr.Min, attr.Max, label);
5152
break;
5253
default:
5354
EditorGUI.LabelField(position, label, new GUIContent("Slider must be of type float, int, Vector2, or Vector2Int"));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.lachee.utilities",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"displayName": "Lachee's Utilities",
55
"description": "Bunch of utility functionality",
66
"unity": "2019.1",

0 commit comments

Comments
 (0)