Scripting: changing texture/material of an instance

Hello all!

I have made many attempts at this without success. The answer may be obvious but I have not been able to find it. Any help would be appreciated!

We have a function in which several (7) clones of the same model are instantiated. We would like to then to change the textures of these clones.

Thank you!

Rick

var prefab : GameObject;

function placeLetters () {

      //Clone first leaf
      var pos = Vector3 (12.4, 34.8, -1.5);
      var leaf = Instantiate(prefab, pos, Quaternion.identity);
     leaf.name = ("letter_leaf_S");
     //Change its texture / shader
     // HELP!

}

Haven’t tried it out, but in the Unity Manual (http://unity3d.com/support/documentation/printable.html) there’s a bit in the Advanced part under

SL-ShaderReplacement

Hope this helps.
Hermit

Thank you for the tip Hermit. I will look into it.

Also look at this (short) thread:
http://forum.unity3d.com/viewtopic.php?t=21414