[Solved] Cannot delete a unity event when using custom editor

I’ve been working on converting some classes to use the new UnityEvent instead of an older in house implementation that relied on reflection.

The problem I came across is that the Delete button (that little “-” sign at the bottom of the list) is disabled when I use a custom editor that draws the event list.

seems related to this thread (that was never answered) : issue with deleting unity event listener when drawn in custom inspector - Unity Engine - Unity Discussions

Was this intentionally disabled by unity due to issues? when are we going to get this back?

To be clear, all i’m doing in my custom inspector is FindProperty(), followed by PropertyField(). Nothing more.
It is very frustrating that this simple supported functionality just doesn’t work for this case with no reason or explanation.

So after hours of messing around with this, it seems to be working again.

I guess the issue must have been me changing the editor code to test things, which somehow caused the internal list to get out of sync, and disallow deletion.

After clearing the entire list, and re-creating it, the button became active once again.

It’s disabled until you click on one of the elements to delete.

Sorry, but that isn’t the case at all.

It will be enabled and delete the last element if you don’t have anything selected.

That’s the behaviour I see on 5.1.1f1 on OSX.

Same Unity version, on windows, if you create a new item, the button is enabled.

And upon further testing, I can confirm, if I change the editor code, and select the object again, the delete button is disabled once more, this time, until i select an element.

Seems that the selected index is updated when you create a new item, but once you load in a different object, or change the code causing a rebuild of the assemblies, the selected index is reset, disabling the button.

You can also see that if you have an item selected in the list (button enabled) and then change a different property (causing focus to be changed to another property altogether) the button stays enabled, since again, the selected index remains cached in the property drawer.