I’m looking at creating a material library, so we can reuse material settings from project to project. In order to reduce search time I would like to be able to export multiple materials into one combined file, so I can’t really use standard .mat files.
The issue here is that you can get a specific keyword or property from a Material, but you can’t get a list of all keywords and properties.
I thought of making a subclass of Material and then registering which calls are made in response to a call to CopyPropertiesFromMaterial, but it’s not possible to do that either.
For editor scripting, ShaderUtil class will help you to retrieve all shader properties. There’s also a minor caveeat. Materials cache shader properties and do not clear that cache so you’d better do not assign another shader to exiting material instance.
Yes, I just found that one. That helps with the properties. Indeed the material could also have properties assigned that the shader doesn’t have, but for a material library that’s no problem.
And for the keywords it seems you can use Material.shaderKeywords, though I’m not 100% sure what “additional” means here. I guess other than global keywords, so it should return just what I need.
I understand, but that’s ok. All I need to know is all keywords that are set by the material. I don’t need to know all available keywords for the shader.