Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the MinMaxSlider to display properly when inspector window is not in wide mode. #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -105,4 +114,4 @@ protected override void OnGUI_Internal(Rect rect, SerializedProperty property, G
EditorGUI.EndProperty();
}
}
}
}