Skip to content

Commit 31c8a16

Browse files
committed
fix: Fixed overflow issue with nested serialized arguments
1 parent cf5f608 commit 31c8a16

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Editor/Drawers/PersistentArgumentDrawer.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ExtEvents.Editor
1+
namespace ExtEvents.Editor
22
{
33
using System;
44
using System.Collections.Generic;
@@ -259,10 +259,13 @@ private static void DrawValueInFoldout(SerializedProperty mainProperty, Serializ
259259
SerializedProperty iterator = valueProperty.Copy();
260260
var nextProp = valueProperty.Copy();
261261
nextProp.NextVisible(false);
262+
bool enterChildren = true;
262263

263-
while (iterator.NextVisible(true) && ! SerializedProperty.EqualContents(iterator, nextProp))
264+
while (iterator.NextVisible(enterChildren) && ! SerializedProperty.EqualContents(iterator, nextProp))
264265
{
265-
shiftedRect.height = EditorGUI.GetPropertyHeight(iterator, false);
266+
// enter children only once.
267+
enterChildren = false;
268+
shiftedRect.height = EditorGUI.GetPropertyHeight(iterator, true);
266269
EditorGUI.PropertyField(shiftedRect, iterator, true);
267270
shiftedRect = shiftedRect.ShiftOneLineDown(lineHeight: shiftedRect.height);
268271
}

Editor/Drawers/PersistentListenerDrawer.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ExtEvents.Editor
1+
namespace ExtEvents.Editor
22
{
33
using System;
44
using System.Collections.Generic;
@@ -153,10 +153,17 @@ private bool DrawArguments(SerializedProperty listenerProperty, List<string> par
153153

154154
EditorGUI.BeginChangeCheck();
155155

156+
float previousPropertyHeight = EditorGUIUtility.singleLineHeight;
157+
156158
for (int i = 0; i < argumentsArray.arraySize; i++)
157159
{
158-
rect.y += EditorGUIUtility.singleLineHeight + EditorPackageSettings.LinePadding;
159160
var argumentProp = argumentsArray.GetArrayElementAtIndex(i);
161+
162+
var propertyHeight = EditorGUI.GetPropertyHeight(argumentProp);
163+
rect.y += previousPropertyHeight + EditorPackageSettings.LinePadding;
164+
rect.height = propertyHeight;
165+
previousPropertyHeight = propertyHeight;
166+
160167
string label = EditorPackageSettings.NicifyArgumentNames ? ObjectNames.NicifyVariableName(paramNames[i]) : paramNames[i];
161168
EditorGUI.PropertyField(rect, argumentProp, GUIContentHelper.Temp(label));
162169
}

0 commit comments

Comments
 (0)