change prefab material

In my game, an object clones itself every 10 seconds in a new spot through the use of instantiate prefab. A button in the game changes the texture of the object, but I don't know how to change the texture of the prefab of the object. thanks ahead of time.

I don't know whether prefabs are accessible in that way outwith the editor. If you're in C#, you could try using a static variable to define what material is applied to all prefabs on load, and then change this variable to change the shader used, by a behaviour within.

something like this: public class ChangerScript(){ public Material pMaterial;

public static Material gMaterial; void Start(){ Renderer vMesh=GetComponent("Renderer") as Renderer; if(gMaterial!=null){ pMesh.material=gMaterial; } }

void Update(){ if (Input.GetKey("m"){ gMaterial=pMaterial; } } } One drag is the need to reset it at the beginning or end of the game. You can also set thisd material elsewhere (from any other script), by setting "ChangerScript.gMaterial".

:)

James

You do it the same way you change anything about a prefab. Either select the prefab in the Project View, and change it there, or instantiate the prefab, change it on the instance, and either choose Apply Changes to Prefab from the GameObject menu, or drag the instance, from the Hierarchy View, onto the prefab in the Project View.

If the issue is that you can't see your texture slots, then click the preview shape next to the name of the material. That shows and hides the properties.