From 490873ce76df3fb6c55be524bac2d4a4f7798d53 Mon Sep 17 00:00:00 2001 From: Robert Wartenberg Date: Thu, 20 Feb 2020 19:59:03 +0100 Subject: [PATCH 1/2] new attrib to fold the list by default --- Editor/ReorderableDrawer.cs | 4 ++-- Editor/ReorderableList.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Editor/ReorderableDrawer.cs b/Editor/ReorderableDrawer.cs index 6910ef9..e8181b8 100644 --- a/Editor/ReorderableDrawer.cs +++ b/Editor/ReorderableDrawer.cs @@ -21,7 +21,7 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent ReorderableList list = GetList(property, attribute as ReorderableAttribute, ARRAY_PROPERTY_NAME); return list != null ? list.GetHeight() : EditorGUIUtility.singleLineHeight; - } + } public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { @@ -85,7 +85,7 @@ public static ReorderableList GetList(SerializedProperty property, ReorderableAt ReorderableList.ElementDisplayType displayType = attrib.singleLine ? ReorderableList.ElementDisplayType.SingleLine : ReorderableList.ElementDisplayType.Auto; - list = new ReorderableList(array, attrib.add, attrib.remove, attrib.draggable, displayType, attrib.elementNameProperty, attrib.elementNameOverride, icon); + list = new ReorderableList(array, attrib.add, attrib.remove, attrib.draggable, displayType, attrib.elementNameProperty, attrib.elementNameOverride, icon, attrib.expanded); list.paginate = attrib.paginate; list.pageSize = attrib.pageSize; list.sortable = attrib.sortable; diff --git a/Editor/ReorderableList.cs b/Editor/ReorderableList.cs index ea5ecf6..046658e 100644 --- a/Editor/ReorderableList.cs +++ b/Editor/ReorderableList.cs @@ -68,6 +68,7 @@ public enum ElementDisplayType { public bool draggable; public bool sortable; public bool expandable; + public bool isExpandedDefault; public bool multipleSelection; public GUIContent label; public float headerHeight; @@ -138,7 +139,7 @@ public ReorderableList(SerializedProperty list, bool canAdd, bool canRemove, boo : this(list, canAdd, canRemove, draggable, elementDisplayType, elementNameProperty, null, elementIcon) { } - public ReorderableList(SerializedProperty list, bool canAdd, bool canRemove, bool draggable, ElementDisplayType elementDisplayType, string elementNameProperty, string elementNameOverride, Texture elementIcon) { + public ReorderableList(SerializedProperty list, bool canAdd, bool canRemove, bool draggable, ElementDisplayType elementDisplayType, string elementNameProperty, string elementNameOverride, Texture elementIcon, bool isExpandedDefault = false) { if (list == null) { @@ -169,9 +170,15 @@ public ReorderableList(SerializedProperty list, bool canAdd, bool canRemove, boo this.elementNameProperty = elementNameProperty; this.elementNameOverride = elementNameOverride; this.elementIcon = elementIcon; + this.isExpandedDefault = isExpandedDefault; id = GetHashCode(); + list.isExpanded = true; + if (!isExpandedDefault){ + list.isExpanded = false; + } + label = new GUIContent(list.displayName); pageInfoContent = new GUIContent(); pageSizeContent = new GUIContent(); From 58a1c0377a5f5c3515488bf0dc6e3fb2ae584d21 Mon Sep 17 00:00:00 2001 From: Robert Wartenberg Date: Thu, 20 Feb 2020 20:22:22 +0100 Subject: [PATCH 2/2] new attrib to fold the list by default --- Runtime/Attributes/ReorderableAttribute.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Runtime/Attributes/ReorderableAttribute.cs b/Runtime/Attributes/ReorderableAttribute.cs index 97ab24f..58a7022 100644 --- a/Runtime/Attributes/ReorderableAttribute.cs +++ b/Runtime/Attributes/ReorderableAttribute.cs @@ -10,6 +10,7 @@ public class ReorderableAttribute : PropertyAttribute { public bool draggable; public bool singleLine; public bool paginate; + public bool expanded; public bool sortable; public bool labels; public int pageSize; @@ -35,7 +36,7 @@ public ReorderableAttribute(string elementNameProperty, string elementNameOverri : this(true, true, true, elementNameProperty, elementNameOverride, elementIconPath) { } - public ReorderableAttribute(bool add, bool remove, bool draggable, string elementNameProperty = null, string elementIconPath = null) + public ReorderableAttribute(bool add, bool remove, bool draggable, string elementNameProperty = null, string elementIconPath = null) : this(add, remove, draggable, elementNameProperty, null, elementIconPath) { }