I current have a custom material editor for which I would like to Override the Unity built-in Context Menu Reset.
Right now I am able to override this Context Menu however, I want to be able to check if the current material is using one of my custom shaders and if so use my (Reset) otherwise use Unity’s Reset.
Anyway to accomplish that?
Since I did not find a way to avoid completely overriding their material reset context menu, I ended up replicating the functionality of the reset.
The implementation is simple. If the material selected is using one of my custom shaders. I simply create a new material of that shader type which gets me a new material with default property values. Copy from the selected material the properties I do not wish to override. Then using Material.CopyPropertiesFromMaterial() I copy the properties of the temporary material back over to the original. Lastly, destroy the temporary material.
In the case of other material, using the same function, I simply copy the properties of the temporary back over the selected material thus the equivalent of a reset.