- Home /
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:
create a gameobject, mesh, etc.
drag a material onto the object
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?
Answer by abdulazizmuneeb · Nov 17, 2021 at 12:28 PM
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?