I have a script that `Instantiate`s a number of objects. When I look them up in the inspector their materials are called "MaterialName (Instance)" and these seem indeed separate instances of the material - if I tweak the parameters of the original material none of the instantiated objects' appearances change. Is it possible to make the Instantiated objects keep the original material instead?
I tried to set `.sharedMaterial` after instantiate, like:
var clone : GameObject = Instantiate(proto);
clone.renderer.sharedMaterial = proto.renderer.material;
but it doesn't help. I guess I lack understanding of how `.material` and `.sharedMaterial` work.
May be the problem is due to my cloning logic (`clouds[ ]` is an array of clones):
// clone the gameObject this script is connected to...
var proto = Instantiate(gameObject);
// make sure this script won't be called on clones
proto.active = false;
// make clones of the proto-clone
for(var i=0; i<clouds.length; ++i) {
clouds *= Instantiate(proto, transform.position, transform.rotation);*
_clouds*.transform.parent = transform;*_
<em>_clouds*.name = "Cloud LOD"+i;*_</em>
<em><em>_clouds*.active = false;*_</em></em>
<em><em>_*// remove this script from the clones*_</em></em>
<em><em><em>_Destroy(clouds*.GetComponent(CloudController));*_</em></em></em>
<em><em><em>_*// [... further cloud setup ...]*_</em></em></em>
<em><em><em>_*}*_</em></em></em>
<em><em><em>_*// destroy the proto-clone*_</em></em></em>
<em><em><em>_*Destory(proto);*_</em></em></em>
<em><em><em>_*```*_</em></em></em>
<em><em><em>_*<p>The reason it's like this is that I want the artists to be able to place and manipulate the prototypes in the editor, then have them spawn their clones at run-time. Among other things they may change the material used for this particular prototype (but also other things, like particle system parameters). </p>*_</em></em></em>
<em><em><em>_*<p>May be that's what I'm doing wrong and there is a better way?</p>*_</em></em></em>