I’ve got a very large scene with many textures - all of which I have baked in Maya.
When I import the scene into Unity, it all works well but all the Shaders by default are Diffuse. I know that if I turn up the Ambient Light, all that baking will show up; but then my character (whom I have not baked is then washed out).
So, is there a way to either:
a) Make the Ambient Light not affect the character or
b) Batch convert a huge bunch of Shaders from Diffuse to Self-Illumin or Light Mapped?
Here you go. Put this script into Editor/Assets. Select some objects in the hierarchy that have Renderers attached. Choose “Change Shaders…” from the GameObject menu, choose a shader and click “Replace Selected”. The script will go through all the selected objects and their children, find their Materials and replace the shader with the chosen one.
Try it out. If you need something more complicated, such as replacing or transferring references, I can do that tomorrow.
Also, I realize it might be better if you could change the Materials directly. I haven’t actually done this before, so that might take me a bit longer. Oh and a more elegant option would be to create a custom asset importer. I’ll think about that too.
I’ve often wished that there was a more robust Assets Importer built into Unity - one that would allow for things like “Import Materials as Self-Illumin” or something like that. The automated “if it’s new in the assets folder, import it” is good sometimes, but it sometimes automates stuff too much and doesn’t provide all the flexibility I sometimes wish it would.
In my opinion, the built-in behaviour for automated material generation is worse than useless. However, you do pretty much whatever you want in an AssetPostprocessor.