Author Topic: How to modify the shader of a material in the editor from code?  (Read 1103 times)


I'm working on a little automation tool to get my substances from the pretty things I see in SD all the way to unity using my own shaders and my own texture layouts all with a single click.

I wrote a python script that modifies the sbs to change the last bits and pack maps together. Another one converts the sbs to a sbsar, another one renders the textures.

I create native materials for people who do not use substance and I'd like to have the substance materials generated correctly as well. I used dotpeek to look at how the editor code for substance looks and I sort understood what's happening. So, I get the materials from the graph, change the shader and the textures bindings. Then I call the commit functions from SubstanceImpoter, mark the substance as dirty and refresh the asset database. This works but only until for some reason the whole substance is reimported and my changes are discarded.

I get that the substance integration is supposed to be bare minimum and I should not expect fancy features like editor integration but could I still do this?