Can I change texture of particle in a script?

particleRenderer.sharedMaterial.mainTexture = texture;

this isn’t working!!! why!!! =/

Get the material of the ParticleRenderer instead of the sharedMaterial, then change the main texture of it.

something like this:

Material material = this.GetComponent<ParticleRenderer>().material;
material.mainTexture = m_newTexture;

Thanks,

I’m sorry I didn’t mention the purpose… sorry.
I’m trying to save up some draw calls by sharing materials between paticles.

doc says that :

“If you need to access shared material properties from the scripts, then it is important to note that modifying Renderer.material will create a copy of the material. Instead, you should use Renderer.sharedMaterial to keep material shared.”

I’m not 100% sure I understand this.
Will it also help batch the materials if I copy the material?

Please lecture me one more time. =O

I found a link that says to use sharedMaterial instead of material “if you can” if anyone is also curious.

http://kimseunghyun76.tistory.com/193