Skip to content

Commit 435001a

Browse files
committed
Fix multi editing error
1 parent 763f588 commit 435001a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,18 @@ TypePopupCache GetTypePopup (SerializedProperty property) {
7676
);
7777
popup.OnItemSelected += item => {
7878
Type type = item.Type;
79-
object obj = m_TargetProperty.SetManagedReference(type);
80-
m_TargetProperty.isExpanded = (obj != null);
81-
m_TargetProperty.serializedObject.ApplyModifiedProperties();
82-
m_TargetProperty.serializedObject.Update();
79+
80+
// Apply changes to individual serialized objects.
81+
foreach (var targetObject in m_TargetProperty.serializedObject.targetObjects) {
82+
SerializedObject individualObject = new SerializedObject(targetObject);
83+
SerializedProperty individualProperty = individualObject.FindProperty(m_TargetProperty.propertyPath);
84+
85+
object obj = individualProperty.SetManagedReference(type);
86+
individualProperty.isExpanded = (obj != null);
87+
88+
individualObject.ApplyModifiedProperties();
89+
individualObject.Update();
90+
}
8391
};
8492

8593
result = new TypePopupCache(popup, state);

0 commit comments

Comments
 (0)