How to be notified when material changes in editor

I’d love to know if I can be notified in code when a material is assigned to an object. Maybe similar to ShaderGUI::AssignNewShaderToMaterial() or some Editor event hook.

What needs to happen is this:

  1. create a gameobject, mesh, etc.
  2. drag a material onto the object
  3. at this point I need to be notified so I can check what material it is, and what gameobject it is, and perform some work

Is this possible?

This is an old thread but I am also looking for an answer to this. Can anyone post a solution to this?

I have tried EditorWindow.OnHierarchyChange() but that doesn’t get called every time a material is changed, only the first time. Scene dirty flag also gets set the first time.

Is there a way to get notified/detect each time a new material is assigned to a game object in editor?