A event on deletion of asset in the asset database?


Is it possible to run a script, if a (specific) object gets deleted in the Project (AssetDatabase) window?

So for example, if a Prefab gets deleted a editor script will run and update other prefabs?

I found the solution!

There seemse to be two ways.

One is to use the AssetModificationProcessor (AssetModificationProcessor.OnWillDeleteAsset())

With this, you can directly hook into the delete process. This is a pro feature only.

The second way and the solution for me (because I don’t want to change the way Unity is deleting assets) is to use the AssetPostprocessor.
With AssetPostprocessor.OnPostprocessAllAssets you get a list of all deleted assets from Unity.

This is exactly what I was looking for!