Anyway to detect for missing material from Renderer component?

I have been loading my assets using assetbundle. But I face a peculiar issue when loading scenes directly from asset bundle, that some of the meshes from scenes are having pink material… even though the material field of mesh renderer contains the material it still show pink rendered material.

One way around this that I found is to re apply material for those meshes after the scene has been loaded and which seems to work for now. But for larger scene this is additional computational cost which I want to get rid of.

So if you can tell me why is it happening in the assetbundle? and how to get rid of it? Otherwise if there is anyway to check whether any mesh has been missing material and is having issue with recompilation of shader?

Maybe this question is outdated. But I suppose that many progers have the same issue. So…

First of all, why the material is pink? Because when you put material to AssetBundle, shader of material aren’t going to be build anymore. And when you load material with shader that isn’t present inside build Unity can’t build it from the bundle. That’s why Unity setup shader of the material to Hidden/Error. This material have pink color.
And that’s what you should do:

  1. If shader isn’t referenced in any other material which included to build, you must add shader in built-in option.

  1. The second step is to setup material.shader field. As I mentioned before, shader stored in assetBundle isn’t compiled, so it’s not going to work. Thats why you must find shader that already built inside your app via script and reset material.shader with it. I highly recomend to set material.shader field to null before set it to actual shader because of some bugs.

    public static void UpdateMaterial(Material material)
            var shader = Shader.Find(;
            material.shader = null;
            material.shader = shader;