How to detect when a prefab instance is replaced?

I have some objects that in edit mode OnValidate add themselves to a list in my level manager, and in OnDestroy remove themselves from the list. This works great, but when I swap a prefab instance using the field on the instance inspector (or via the right click menu in the hierarchy), OnDestroy is not called, leaving behind a null item in the list.

Is there an editor function or event that will tell me when this replace happens?

Dropping a new one into that slot should not leave a blank / null.

I’m guessing the problem is caused by you Destroy()-ing them in the first place.

Why not just revalidate the list in OnValidate() each time? If they are assets on disk you cannot Destroy() them that way anyway. You just stop referencing them.