Skip to content

Commit

Permalink
Fixed invalid detection of expandable properties. HasVisibleChildren …
Browse files Browse the repository at this point in the history
…was not enough.
  • Loading branch information
Chris committed May 11, 2017
1 parent 024de74 commit 76947ec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions Assets/ReorderableList/Example/Editor/ExampleEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public override void OnInspectorGUI() {

//Draw without caching property
EditorGUILayout.PropertyField(serializedObject.FindProperty("list4"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("list5"));

serializedObject.ApplyModifiedProperties();
}
Expand Down
9 changes: 8 additions & 1 deletion Assets/ReorderableList/Example/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Malee;

public class Example : MonoBehaviour {

public List<ExampleChild> list1;

[Reorderable]
Expand All @@ -16,6 +16,9 @@ public class Example : MonoBehaviour {
[Reorderable]
public StringList list4;

[Reorderable]
public VectorList list5;

[System.Serializable]
public class ExampleChild {

Expand All @@ -38,4 +41,8 @@ public class ExampleChildList : ReorderableArray<ExampleChild> {
[System.Serializable]
public class StringList : ReorderableArray<string> {
}

[System.Serializable]
public class VectorList : ReorderableArray<Vector3> {
}
}
21 changes: 19 additions & 2 deletions Assets/ReorderableList/List/Editor/ReorderableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ private float GetElementHeight(SerializedProperty element) {
}
else {

return EditorGUI.GetPropertyHeight(element, GUIContent.none, true) + 5;
return EditorGUI.GetPropertyHeight(element, GetElementLabel(element), true) + 5;
}
}

Expand Down Expand Up @@ -1392,7 +1392,7 @@ private bool IsElementExpandable(SerializedProperty element) {

case ElementDisplayType.Auto:

return element.hasVisibleChildren && element.propertyType != SerializedPropertyType.ObjectReference;
return element.hasVisibleChildren && IsTypeExpandable(element.propertyType);

case ElementDisplayType.Expandable:

Expand All @@ -1406,6 +1406,23 @@ private bool IsElementExpandable(SerializedProperty element) {
return false;
}

private bool IsTypeExpandable(SerializedPropertyType type) {

switch (type) {

case SerializedPropertyType.Generic:
case SerializedPropertyType.Vector4:
case SerializedPropertyType.Quaternion:
case SerializedPropertyType.ArraySize:

return true;

default:

return false;
}
}

//
// -- LIST STYLE --
//
Expand Down

0 comments on commit 76947ec

Please sign in to comment.