Convert Legacy Shaders to Standard in Batch

Hey there,

is there a way to set all shaders in my scene from legacy to the new standard one? I’ve got around 1000 different materials in this scene so of course I dont want to change them one by one.

Thanks in advance
AirRic

Hmm, should be possible. Rough outline:

  1. Load all Material in the Resources folder into an array using Resoures.LoadAll()
  2. Iterate through the array: Create a new temporary material from script using Material newMat = new Material(Shader.Find(“Standard”));
  3. Copy all shader properties from the Legacy material to the appropriate properties of the temp mat (things like mainTexture, color, normal map etc… This needs to be done by hand since not all properties overlap and you might have to do different dub-functions for different legacy shaders)
  4. Change the legacy material’s shader to Standard
  5. Copy the properties from the temp material to the old/new material using tempMat.CopyPropertiesFromMaterial(oldMat);

So there is really no build-in function? I can’t imagine that I am the only one with this problem … and the Unity devs didnt think about this properly …

It’s impossible to make a converter that can convert every kind of shader, custom or legacy, to the new Standard shader. Writing a function like the one outlined above is trivial, however.