Skip to content

Commit

Permalink
Fixed nested reorderable list inspector height
Browse files Browse the repository at this point in the history
• Fixed improper calculations of the element heights in the Avatar Slots reorderable list.
  • Loading branch information
Nestorboy committed Jan 30, 2024
1 parent 79bc20d commit f5e7fef
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ ReorderableList GetInstructionRList(int index)
draggable = false,

elementHeight = propertyInstructions.isExpanded ? 20f : 0f,
footerHeight = 2f,

drawHeaderCallback = (Rect rect) =>
{
Expand Down Expand Up @@ -226,13 +227,21 @@ ReorderableList GetInstructionRList(int index)

ReorderableList instructionRList = GetInstructionRList(index);

float height = 0f;
height += 4f; // Element padding.
height += instructionRList.headerHeight; // Fit header.
height += Math.Max(instructionRList.count * instructionRList.elementHeight, instructionRList.elementHeight); // Fit elements.
height += 4f; // Bottom padding.
height += 4f; // Top padding.
return height;
float headerHeight = instructionRList.headerHeight;

int elementCount = instructionRList.count;
float elementHeight = instructionRList.elementHeight;
bool isExpanded = instructionRList.elementHeight > 0;
bool hasElements = elementCount > 0;
if (isExpanded && hasElements) elementHeight += 2f;
float elementsHeight = 0f;
elementsHeight += 4f; // listElementTopPadding.
elementsHeight += Math.Max(elementCount * elementHeight, elementHeight); // Sum of element heights.
elementsHeight += 4f; // kListElementBottomPadding.

float footerHeight = instructionRList.footerHeight;

return headerHeight + elementsHeight + footerHeight;
},
};

Expand Down

0 comments on commit f5e7fef

Please sign in to comment.