Changing shader in editor resets the texture

I wrote a simple script to change the shader in the editor, the problem is the texture gets “reset” (as if I clicked “reset” on the material, and then changed the shader)

    var shader = Shader.Find("HoloToolkit/Vertex Lit Configurable Transparent");
    var renderer = gameObject.GetComponent<Renderer>();
    for (int i = 0; i < renderer.sharedMaterials.Length; i++)
        renderer.sharedMaterials*.shader = shader;*

renderer.sharedMaterials*.SetFloat("UseColor", 1);
renderer.sharedMaterials.SetFloat("UseMainTex", 1);*

Any idea what I’m doing wrong?

It depends on the name of the texture property. If both shaders’ Main Texture property is “_MainTex” then the texture will stay when switching shaders. If the properties are spelled differently, then it won’t. So I have to ask, are the Main Texture properties the same in both shaders?