Skip to content

Commit e4cbe10

Browse files
author
Christopher - Marcel Böddecker
committed
fix(MemberChange): only show undo/redo warning for change handlers
1 parent 91a0355 commit e4cbe10

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

Sources/FodyRunner.UnityIntegration/InspectorEditor.cs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,42 +82,40 @@ public override void OnInspectorGUI()
8282
FindChangeHandlerMethods(property);
8383
}
8484

85-
if (!changeCheckScope.changed
86-
|| !Application.isPlaying
87-
|| targetObject is Behaviour behaviour && !behaviour.isActiveAndEnabled)
85+
if (changeCheckScope.changed
86+
&& Application.isPlaying
87+
&& (!(targetObject is Behaviour behaviour) || behaviour.isActiveAndEnabled)
88+
&& ChangeHandlerMethodInfos.Count > 0)
8889
{
89-
if (changeCheckScope.changed)
90-
{
91-
ApplyModifiedProperty(property, ChangeHandlerMethodInfos.Count > 0);
92-
}
93-
94-
continue;
95-
}
96-
}
97-
98-
Undo.RecordObject(targetObject, "Before change handlers");
99-
BeforeChange(property);
100-
Undo.FlushUndoRecordObjects();
90+
Undo.RecordObject(targetObject, "Before change handlers");
91+
BeforeChange(property);
92+
Undo.FlushUndoRecordObjects();
10193

102-
using (SerializedObject serializedObjectCopy =
103-
new SerializedObject(property.serializedObject.targetObject))
104-
{
105-
SerializedProperty propertyCopy = serializedObjectCopy.GetIterator();
106-
if (propertyCopy.Next(true))
107-
{
108-
do
94+
using (SerializedObject serializedObjectCopy =
95+
new SerializedObject(property.serializedObject.targetObject))
10996
{
110-
if (propertyCopy.propertyPath != property.propertyPath)
97+
SerializedProperty propertyCopy = serializedObjectCopy.GetIterator();
98+
if (propertyCopy.Next(true))
11199
{
112-
property.serializedObject.CopyFromSerializedProperty(propertyCopy);
100+
do
101+
{
102+
if (propertyCopy.propertyPath != property.propertyPath)
103+
{
104+
property.serializedObject.CopyFromSerializedProperty(propertyCopy);
105+
}
106+
}
107+
while (propertyCopy.Next(false));
113108
}
114109
}
115-
while (propertyCopy.Next(false));
110+
111+
ApplyModifiedProperty(property, true);
112+
AfterChange(property);
113+
}
114+
else if (changeCheckScope.changed)
115+
{
116+
ApplyModifiedProperty(property, ChangeHandlerMethodInfos.Count > 0);
116117
}
117118
}
118-
119-
ApplyModifiedProperty(property, true);
120-
AfterChange(property);
121119
}
122120
while (property.NextVisible(false));
123121
}

0 commit comments

Comments
 (0)