Skip to content

Commit

Permalink
Upgraded RangeSlider to work in both Horizontal and Verticle setups, …
Browse files Browse the repository at this point in the history
…just like regular slider.

Also fixed a minor issue with offset when dragging on the bar.

# Conflicts:
#	Runtime/Scripts/Controls/RangeSlider.cs
  • Loading branch information
Dover8 committed Mar 21, 2022
1 parent d47b99c commit 33568a6
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 61 deletions.
13 changes: 12 additions & 1 deletion Editor/RangeSliderEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace UnityEngine.UI.Extensions
[CanEditMultipleObjects]
public class RangeSliderEditor : SelectableEditor
{
SerializedProperty m_Direction;
SerializedProperty m_LowHandleRect;
SerializedProperty m_HighHandleRect;
SerializedProperty m_FillRect;
Expand All @@ -36,6 +37,7 @@ protected override void OnEnable()
m_LowHandleRect = serializedObject.FindProperty("m_LowHandleRect");
m_HighHandleRect = serializedObject.FindProperty("m_HighHandleRect");
m_FillRect = serializedObject.FindProperty("m_FillRect");
m_Direction = serializedObject.FindProperty("m_Direction");

m_MinValue = serializedObject.FindProperty("m_MinValue");
m_MaxValue = serializedObject.FindProperty("m_MaxValue");
Expand Down Expand Up @@ -66,6 +68,16 @@ public override void OnInspectorGUI()
if (m_LowHandleRect.objectReferenceValue != null && m_HighHandleRect.objectReferenceValue != null)
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_Direction);
if (EditorGUI.EndChangeCheck())
{
RangeSlider.Direction direction = (RangeSlider.Direction)m_Direction.enumValueIndex;
foreach (var obj in serializedObject.targetObjects)
{
RangeSlider rangeSlider = obj as RangeSlider;
rangeSlider.SetDirection(direction, true);
}
}

EditorGUILayout.PropertyField(m_MinValue);
EditorGUILayout.PropertyField(m_MaxValue);
Expand Down Expand Up @@ -120,4 +132,3 @@ public override void OnInspectorGUI()
}

}

Loading

0 comments on commit 33568a6

Please sign in to comment.