Hi guys!
I am having huge troubles with materials leaking into the scene. I am changing the properties of a lot of materials like changing the textures and changing the colors.
I have found this post http://forum.unity3d.com/viewtopic.php?t=26293 that suggest manually creating and destroying materials when changing properties, but I can’t seem to get it to work.
This is what I am doing:
Material mat = new Material(renderer.material);
renderer.material = mat;
// Function called on Destroy
void Destroy(){
Destroy(mat);
}
However this doesn’t stop the accumulation of material instances. What am I doing wrong?