diff --git a/Assets/ReorderableList/List/Attributes/ReorderableAttribute.cs b/Assets/ReorderableList/List/Attributes/ReorderableAttribute.cs index 3be37df..7a96569 100644 --- a/Assets/ReorderableList/List/Attributes/ReorderableAttribute.cs +++ b/Assets/ReorderableList/List/Attributes/ReorderableAttribute.cs @@ -9,6 +9,7 @@ public class ReorderableAttribute : PropertyAttribute { public bool draggable; public bool singleLine; public bool paginate; + public bool sortable; public int pageSize; public string elementNameProperty; public string elementNameOverride; @@ -39,9 +40,10 @@ public ReorderableAttribute(bool add, bool remove, bool draggable, string elemen this.add = add; this.remove = remove; this.draggable = draggable; + this.sortable = true; this.elementNameProperty = elementNameProperty; this.elementNameOverride = elementNameOverride; this.elementIconPath = elementIconPath; } } -} \ No newline at end of file +} diff --git a/Assets/ReorderableList/List/Editor/ReorderableDrawer.cs b/Assets/ReorderableList/List/Editor/ReorderableDrawer.cs index de0eb2a..dc38c9c 100644 --- a/Assets/ReorderableList/List/Editor/ReorderableDrawer.cs +++ b/Assets/ReorderableList/List/Editor/ReorderableDrawer.cs @@ -81,6 +81,7 @@ public static ReorderableList GetList(SerializedProperty property, ReorderableAt list = new ReorderableList(array, attrib.add, attrib.remove, attrib.draggable, displayType, attrib.elementNameProperty, attrib.elementNameOverride, icon); list.paginate = attrib.paginate; list.pageSize = attrib.pageSize; + list.sortable = attrib.sortable; } else { @@ -98,4 +99,4 @@ public static ReorderableList GetList(SerializedProperty property, ReorderableAt return list; } } -} \ No newline at end of file +} diff --git a/Assets/ReorderableList/List/Editor/ReorderableList.cs b/Assets/ReorderableList/List/Editor/ReorderableList.cs index b62238b..7eb888a 100644 --- a/Assets/ReorderableList/List/Editor/ReorderableList.cs +++ b/Assets/ReorderableList/List/Editor/ReorderableList.cs @@ -57,6 +57,7 @@ public enum ElementDisplayType { public bool canAdd; public bool canRemove; public bool draggable; + public bool sortable; public bool expandable; public bool multipleSelection; public GUIContent label; @@ -632,23 +633,24 @@ private void DrawHeader(Rect rect, GUIContent label) { } //draw sorting options + if (sortable) { + Rect sortRect1 = rect; + sortRect1.xMin = rect.xMax - 25; + sortRect1.xMax = rect.xMax; - Rect sortRect1 = rect; - sortRect1.xMin = rect.xMax - 25; - sortRect1.xMax = rect.xMax; + Rect sortRect2 = rect; + sortRect2.xMin = sortRect1.xMin - 20; + sortRect2.xMax = sortRect1.xMin; - Rect sortRect2 = rect; - sortRect2.xMin = sortRect1.xMin - 20; - sortRect2.xMax = sortRect1.xMin; + if (EditorGUI.DropdownButton(sortRect1, Style.sortAscending, FocusType.Passive, Style.preButton)) { - if (EditorGUI.DropdownButton(sortRect1, Style.sortAscending, FocusType.Passive, Style.preButton)) { - - SortElements(sortRect1, false); - } + SortElements(sortRect1, false); + } - if (EditorGUI.DropdownButton(sortRect2, Style.sortDescending, FocusType.Passive, Style.preButton)) { + if (EditorGUI.DropdownButton(sortRect2, Style.sortDescending, FocusType.Passive, Style.preButton)) { - SortElements(sortRect2, true); + SortElements(sortRect2, true); + } } } @@ -2627,4 +2629,4 @@ private static object[] GetParams(ref object[] parameters, int count) { } } } - \ No newline at end of file +