Altering Material through Script Causes Transparent Rendering Error - C#

I simply need to swap a material on an object with multiple materials. If I run a for loop like so:

public Material newMat;

myMats = render.sharedMaterials

for(int i = 0; i < myMats.length; i++)
{

 if(myMats*.someProperty == someCheck)*

{
myMats = new Material(newMat);
}
}
… or any variation of this, the Material simply doesn’t change.
Alternatively, I thought I could use something like this, changing the material’s properties, rather than the material altogether:
if(myMats*.someProperty == someCheck)*
{
myMats*.shader = newMat.shader;*
myMats*.CopyPropertiesFromMaterial(newMat);*
}
… This almost does exactly what I need, but if the material changes from an opaque rendering mode to a fade, for example, all of the properties change, but the material doesn’t render properly until I manually change something in the inspector (for example, nudging the color bar). After I touch the material manually, it corrects itself and renders as it should. This isn’t helpful though, as it should be automatically updated in game.
Is this a known Unity bug, or is there a way to update/refresh the shader after applying changes? Any feedback is appreciated. Here are some screenshots to better explain my problem. The first is the material before the change, the second is how it SHOULD look after the change, but the third is my actual result.
[49745-example.jpg|49745]

Uhm, where do you actually assign the material(s) to your renderer(s)? “myMats” seems to be an array of Material references. When you exchange a material in that array, the material that your renderer uses isn’t changed.

If you use the “.materials” or “.sharedMaterials” array property of your renderer, you get a new array containing the used material. If you want to change them you have to assign the array back:

Material[] myMats = renderer.materials;

// do your changes

renderer.materials = myMats;

Keep in mind that when using “.materials” or “.material” Unity will create a copy of each material just for this instance. This might be relevant for drawcalls. The “sharedMaterial(s)” contain direct references to the actual material(s). However exchanging a material in the sharedMaterials array has to be done the same way:

Material[] myMats = renderer.sharedMaterials;

// do your changes

renderer.sharedMaterials = myMats;