Skip to content

Commit

Permalink
Force properties to be folded if there are no children to draw
Browse files Browse the repository at this point in the history
  • Loading branch information
arimger committed Nov 7, 2024
1 parent 4148d81 commit 03993d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ static ScrollableItemsAttributeDrawer()

private static readonly PropertyDataStorage<Vector2, ScrollableItemsAttribute> storage;


private void DrawSettingsBody(SerializedProperty property, ScrollableItemsAttribute attribute, out int size, out Vector2 indexRange)
{
EditorGUILayout.PropertyField(property.GetSize());
Expand Down Expand Up @@ -53,7 +52,6 @@ private void DrawElementsBody(SerializedProperty property, ScrollableItemsAttrib
}
}


protected override void OnGuiSafe(SerializedProperty property, GUIContent label, ScrollableItemsAttribute attribute)
{
using (var propertyScope = new PropertyScope(property, label))
Expand All @@ -70,7 +68,6 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label,
}
}


private static class Style
{
//TODO: apply custom styling for the drawer
Expand Down
5 changes: 4 additions & 1 deletion Assets/Editor Toolbox/Editor/Internal/PropertyScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public void Dispose()
Close();
}

public bool IsVisible => property.isExpanded;
/// <summary>
/// Indicates whether property is expanded and has any children to draw.
/// </summary>
public bool IsVisible => property.isExpanded && property.hasVisibleChildren;
public Rect LabelRect { get; private set; }
public Rect InputRect { get; private set; }
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Examples/Scripts/SampleBehaviour6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class ClassWithInterface4 : ClassWithInterface2
public int var33;
}

#endregion
#endregion

#region Generic Types

Expand Down

0 comments on commit 03993d8

Please sign in to comment.