Skip to content

Commit c5ef3b8

Browse files
committed
Fixed the selection callback not working for multiple objects.
1 parent 2ca7da6 commit c5ef3b8

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

Scripts/Editor/Core/CollectionItemDropdown.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,21 @@ private void InvokeOnSelectCallback(ScriptableObject from, ScriptableObject to)
133133
if (onSelectCallbackMethod == null)
134134
return;
135135

136-
object target = onSelectCallbackMethod.IsStatic ? null : serializedProperty.serializedObject.targetObject;
137-
onSelectCallbackMethod.Invoke(target, new object[] {from, to});
136+
object[] arguments = { from, to };
137+
138+
// The method may be static, in which case there is no target.
139+
if (onSelectCallbackMethod.IsStatic)
140+
{
141+
onSelectCallbackMethod.Invoke(null, arguments);
142+
return;
143+
}
144+
145+
// Otherwise, fire the callback on every target.
146+
for (int i = 0; i < serializedProperty.serializedObject.targetObjects.Length; i++)
147+
{
148+
object target = serializedProperty.serializedObject.targetObjects[i];
149+
onSelectCallbackMethod.Invoke(target, arguments);
150+
}
138151
}
139152

140153
protected override void ItemSelected(AdvancedDropdownItem item)

0 commit comments

Comments
 (0)