Material not initalized (is hazy)??? Must select "standard" shader even when it's already selected?

I have created asset bundles of objects from .fbx models.

I use standard shader on the model.

When I load the asset bundle it is very hazy looking.

If I click the material and select the shader, I must click “standard” (which is already selected) and the material looks normal again, just poof and it’s fixed!!???

But I can not click that option at runtime and to do so would be combersom.

Why is all assetbundle materials hazy until clicked?

I have even tried adding blank normal maps and turning on and off all options, nothing works until I change the shader,

I need to get this fixed!

Please please, help!

[Edit]

Just wrote a script to look at all exposed variables and see if anything changes:

        Debug.Log(material.GetColor ("_Color"));
        Debug.Log(material.GetTexture ("_MainTex"));
        Debug.Log(material.GetFloat ("_Cutoff"));
        Debug.Log(material.GetFloat ("_Glossiness"));
        Debug.Log(material.GetFloat ("_GlossMapScale"));
        Debug.Log(material.GetFloat ("_SmoothnessTextureChannel"));
        Debug.Log(material.GetFloat ("_Metallic"));
        Debug.Log(material.GetTexture ("_MetallicGlossMap"));
        Debug.Log(material.GetFloat ("_SpecularHighlights"));
        Debug.Log(material.GetFloat ("_GlossyReflections"));
        Debug.Log(material.GetFloat ("_BumpScale"));
        Debug.Log(material.GetTexture ("_BumpMap"));
        Debug.Log(material.GetFloat ("_Parallax"));
        Debug.Log(material.GetTexture ("_ParallaxMap"));
        Debug.Log(material.GetFloat ("_OcclusionStrength"));
        Debug.Log(material.GetTexture ("_OcclusionMap"));
        Debug.Log(material.GetColor ("_EmissionColor"));
        Debug.Log(material.GetTexture ("_EmissionMap"));
        Debug.Log(material.GetTexture ("_DetailMask"));
        Debug.Log(material.GetTexture ("_DetailAlbedoMap"));
        Debug.Log(material.GetFloat ("_DetailNormalMapScale"));
        Debug.Log(material.GetTexture ("_DetailNormalMap"));
        Debug.Log(material.GetFloat ("_UVSec"));
        Debug.Log(material.GetFloat ("_Mode"));
        Debug.Log(material.GetFloat ("_SrcBlend"));
        Debug.Log(material.GetFloat ("_DstBlend"));
        Debug.Log(material.GetFloat ("_ZWrite"));

However when i click on “standard” and see the mat change from hazy to normal, I print the above but results are exactly the same, so I don’t think it’s any of those.

This occurs both in editor and full builds.

Reading this thread people say the Standard Shader gets pulled out of asset bundles?? How can I work around it?

After reading this post I was able to implement an actual working solution.
But looking at it, it’s clunky and servers to only add more complexity and make my scripts look horrendous.

However Unity appears to be crippled in the asset bundle department, so hacking around it’s bugs are common place I suppose.

Here is a script that will change the shader of every renderer of the newly created asset prefab gameobject. it will use the existing shader’s name to search for the project’s shader, then sets the material to use the project shader:
THIS IS NOT WORKING

    public static void RefreshShader(GameObject go) // because shadow for assetbundle is cucked.
    {
        var renderers = go.GetComponentsInChildren<Renderer>();
        for (int i = 0; i < renderers.Length; i++)
        {
            renderers [i].material.shader = Shader.Find (renderers [i].material.shader.name);
            UnityEngine.Debug.Log (renderers [i]);
        }
    }

recap,
It seems the shader in the asset bundle is called “standard shader”, but it actually is something entirely different. So by using it’s name, I am able to set the proper shader by locating the shader contained in the project.

[EDIT]
Seeing some changes, the hazy appearance has vanished, but other things are showing z dept issues.

But again, I click the material and hair returns to normal. it changes like freakin magic. No idea why standard materials are so screwy but I’m still completely stuck on how to do this.

[UPDATE]

Finally got something working that doesn’t require setting shaders, simple setting of some keywords and ensuring the render queue is properly set and things are looking better:

THIS IS NOT WORKING

    public static void RefreshShader(GameObject go)
    {
        var renderers = go.GetComponentsInChildren<Renderer>();
        for (int i = 0; i < renderers.Length; i++)
        {
            var material = renderers [i].material;
            //material.shader = Shader.Find (renderers [i].material.shader.name);
            material.DisableKeyword("_ALPHATEST_ON");
            material.EnableKeyword("_ALPHABLEND_ON");
            material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
            material.renderQueue = 3000;
        }
    }

It’s still a real shame those values are not set automatically for whatever reason…???

Still not working, I still see standard shaders acting strange (z-dept issues) until I physically click on the material dropdown.

Does this happen to any other’s out there?

I think Unity is unable to create/load asset bundles properly, which is a little surprising.

[Update]
I realized that I needed to keep the renderQueue in same order as when asset was built.

Instead of setting all to 3000, I now store the renderQueue value in a component attached to renderer, then when I load the asset, I check that value and set the shader.

Weirdly though, I still must replace the assets standard shader with the project’s standard shader (by searching for its name) otherwise issue occur.

However I believe I got things working now.

still surprised that assetbundle have issues keeping track of shader parameters… meh…