I am using this code to change the main texture of the same material in many 3d buttons but am getting this error, what is the proper solution ? (sharedMaterial doesn’t work for my purpose ie: it doesn’t change the texture for each button but for all of them)
void OnWillRenderObject()
{
renderer.material.mainTexture = texture;
}
ERROR:
Instantiating material due to calling renderer.material during edit mode. This will leak materials into the scene. Please use renderer.sharedMaterial instead.[/code]