Skip to content

Commit

Permalink
Workaround a NullReferenceException when working with UI EventTrigger…
Browse files Browse the repository at this point in the history
… events
  • Loading branch information
lyuma committed Nov 3, 2019
1 parent 6272faa commit 31c12e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion EasyEventEditor.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ void DrawInvokeField(Rect position, float headerStartOffset)
MethodInfo invokeMethod = InvokeFindMethod("Invoke", dummyEvent, dummyEvent, PersistentListenerMode.EventDefined);
FieldInfo serializedField = currentProperty.serializedObject.targetObject.GetType().GetField(currentProperty.name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

object[] invokeTargets = currentProperty.serializedObject.targetObjects.Select(target => target == null ? null : serializedField.GetValue(target)).Where(f => f != null).ToArray();
object[] invokeTargets = currentProperty.serializedObject.targetObjects.Select(target => target == null || serializedField == null ? null : serializedField.GetValue(target)).Where(f => f != null).ToArray();

EditorGUI.BeginDisabledGroup(invokeTargets.Length == 0 || invokeMethod == null);

Expand Down

0 comments on commit 31c12e7

Please sign in to comment.