How can i change detail texture?

I have a gameobject with a “Diffuse Detail” shader.

Unity - Manual: Diffuse Detail ← here’s a quick info about that shader

this shader can have two texture. The “Base” and “Detail”.

The base texture can be change using material.mainTexture

but what i want to “change/add/remove” is the detail texture, because i want the base texture retained.

can someone help me with this?

thank you in advance! ^^,

material.mainTexture is a shortcut for material.SetTexture( ... );. So, of course you’ll be using SetTexture for the second texture. The tricky part, is, you have to use the actual variable name in the shader, which is hard to find.

To find the correct name, download the Unity “built-in shaders” source code. The file name for diffuseDetail is Normal-DiffuseDetail. Open it in Notepad (or the Mac equivalent) and you’ll see Shader "Diffuse Detail", telling you it’s the correct one. Scrolling over a little you’ll see _Detail ("Detail (RGB)", 2D) = "grey". This says the texture slot you see as Detail(RGB) is really named _Detail.

So (not tested recently,) use material.SetTexture("_Detail", tex2); If you get the name wrong, there won’t be an error – it just won’t do anything.