Batch Convert Shader Type

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?

Thanks!

I can write an editor script to do that later tonight.

That would be awesome! This is something I’ve wondered about for a long time as well. I’d really appreciate such a script Daniel. Thanks in advance.

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.

217622–7926–$changeshader_191.cs (854 Bytes)

Thanks Daniel. I’ll give this a close look today.

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.

Thanks for your help on this idea.

Sounds like this might be useful to you:

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.

Cool. I’ll have to do a lot more research into that. Thanks.

Nice script but I found it works on hierarchy objects only. Is it possible to work in the Project items?

I like this better: Is there a way to change the shader on all meshes without doing it manually one by one? - Questions & Answers - Unity Discussions