Multiple materials on one mesh

I have unity5 and i’m trying to alter, through script multiple materials that are on the same mesh.

i am currently using the following style of code -

			GameItemObjectThingy.GetComponent<Renderer> ().sharedMaterials[0].CopyPropertiesFromMaterial(materialForGO);
			GameItemObjectThingy.GetComponent<Renderer> ().sharedMaterials[1].CopyPropertiesFromMaterial(secondMatForGO);

it works! which is great, but it only copies, it does not use the same material, and so batching is out :frowning:

What i am looking to do is the same thing but using the same material so it can be batched rather than making a copy of the material.

if i do the following -

GameItemObjectThingy.GetComponent<Renderer> ().sharedMaterials[0]= materialForGO;
GameItemObjectThingy.GetComponent<Renderer> ().sharedMaterials[1]= secondMatForGO;

it does not work. anyone got any ideas?

Material materials=GameItemObjectThingy.GetComponent ().sharedMaterials;
materials[0]=materialForGO;
materials[1]=secondMatForGO;
GameItemObjectThingy.GetComponent ().sharedMaterials=materials;