From f5e7fef0ced1141170deb90d8b0b2557d8b5f17a Mon Sep 17 00:00:00 2001 From: Nestorboy <35258953+Nestorboy@users.noreply.github.com> Date: Tue, 30 Jan 2024 03:07:09 +0100 Subject: [PATCH] Fixed nested reorderable list inspector height MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fixed improper calculations of the element heights in the Avatar Slots reorderable list. --- .../Scripts/Editor/NUSaveStateInspector.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Assets/Nessie/Udon/NUSaveState/Scripts/Editor/NUSaveStateInspector.cs b/Assets/Nessie/Udon/NUSaveState/Scripts/Editor/NUSaveStateInspector.cs index a5a3169..7abdf63 100644 --- a/Assets/Nessie/Udon/NUSaveState/Scripts/Editor/NUSaveStateInspector.cs +++ b/Assets/Nessie/Udon/NUSaveState/Scripts/Editor/NUSaveStateInspector.cs @@ -77,6 +77,7 @@ ReorderableList GetInstructionRList(int index) draggable = false, elementHeight = propertyInstructions.isExpanded ? 20f : 0f, + footerHeight = 2f, drawHeaderCallback = (Rect rect) => { @@ -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; }, };