runtime changing detail albedo map

Hi. I have seen this question before but not found an answer. I am trying to change the detail albedo map in runtime for the standard shader material. While I can change it ok, the object doesn’t show it in the scene or game window unless I expand the material in the inspector. When I do this, it is fine in all windows. Is there something I’m missing?

I think you might be modifying the shared material. If you modify the object own material (using MeshRenderer.material) the changes will happen immediately and only to the one object (and not others of the same material).

I don’t know if this is the cause of your problem though. Best of luck!

same problem. looking for solution

        myRenderer.material.SetTexture("_MainTex", MyTexture);
        or
        myRenderer.material.mainTexture = MyTexture;

You need to enable keywords for each map you update at runtime. For Detail Albedo you need to add:

myRenderer.material.EnableKeyword("_DETAIL_MULX2");
myRenderer.material.SetTexture("_DetailAlbedoMap", MyTexture);
8 Likes

This thread helped me 1.5 years later on Unity 5.6.03f3. Thanks inewland! You had the solution that worked.

I had the same symptoms described by yoonity where the detail texture would only show up when the material component was expanded.

Two years later this helped me too. I was erroneously trying

    myRenderer.material.EnableKeyword("_DetailAlbedoMap");
    myRenderer.material.SetTexture("_DetailAlbedoMap", MyTexture);

Docs cited _DETAIL_MULX2 and I was also using erroneously Unity - Manual: Using materials with C# scripts

material.EnableKeyword() is not helping me…Plzz check my code
go.GetComponent().materials[k].EnableKeyword(“_DETAIL_MULX2”);
go.GetComponent().materials[k].SetTexture(“_DetailAlbedoMap”, aoTexture);
I am downloading materials via one Assetbundle and AOMap via second and then i am applying…
the detail texture would only show up when the material component was expanded.

7 Years later this helped me, too.