Material Instances Problem.

I’m having a problem with a GameObject that contains 2 materials.
I’m doing the following:

renderer.sharedMaterials[ 1 ] = Resources.Load( materialPath ) as Material;
renderer.materials[ 0 ].mainTexture = Resources.Load( texturePath ) as Texture;

So i’m trying to change the 2nd material in all GameObjects but keeping it batched. This works until i change the 1st material’s mainTexture to a different one in each GameObject, after doing this the 2nd material becomes an Instance.

I would like to know if its possible to have one of the materials batch and the other be an instance.
Thank’s in advance.

If you change any property of a material at runtime…and that includes changing any material in the materials array…you get a new material instance. The typical solution to this problem is to use a texture atlas. That way you can have multiple textures combined in to a single texture and therefore use a single material to present multiple different (and differently textured) objects.