Removing Texture at Runtime Without replacing it

I’m pretty new to Unity still, I have a multi-layered material where I need to remove one of the textures of the material during runtime. I don’t want to waste memory setting a new clear texture. Can anyone point me in the right direction?

I should note, using Destroy on a layer seems to destroy the entire material. For example:

If I do this:

gameObject.renderer.materials[1].mainTexture = new Texture2D(1,1);

it works, but may be a waste of memory. Open to something better. Thanks.

This isn’t really one “multilayered material” but simple two materials attached to the same renderer. That simply means the object is drawn twice, one time with the first material and one time with the second. You also don’t replace / remove the material, you just set a new texture fot the material.

Multiple materials are usually used when your Mesh contains submeshes, so each material corresponds to a submesh. If there’s only one submesh in the mesh it is simply drawn twice.

To remove the second material you have to replace the materials array and only include those materials you want to keep:

// C#
Material[] tmp = gameObject.renderer.materials;
gameObject.renderer.materials = new Material[] {tmp[0]};

May i ask why there are actually two materials when you want to remove one at runtime? I don’t get the point.