How do I access secondary maps through c#

1

I have been trying to figure out how to
access this second detail texture
through c# since you access the normal one using renderer.material.maintexture
however I can’t seem to access this detail one.

I have looked around a bit but haven’t found a solution
can someone help?

You can use renderer.material.SetTexture(“_DetailAlbedoMap”, texture). You can find the texture names (like _MainTex) if you right-click the inspector switch to Debug mode (under Saved Properties). You could also download the standard texture pack from the site and read the texture scripts, though the standard shader is very complicated.

Note that if you mess with material properties for a lot of objects, then this will duplicate a lot of materials. Calling renderer.material will duplicate the material unless that render already has exclusive use of the material. You can mess around with render.sharedMaterial, but that often leads to unexpected results. (Still useful for changes to a group of renderers at once.) The best way is generally renderer.SetPropertyBlock. It is a bit more cumbersome to use, but the way it works is that it keeps a set of overrides to the material for the specific renderer. When you set the block, it wipes out the old set of overrides and replaces it with the set you give it. Also, when you call SetPropertyBlock, it copies those fields internally, so you only need to allocate one block object for each set of fields.