- Home /
Material on LineRenderer problem
Hi, I am having a really hard time getting rid of memory leaks while making any changes to the material on LineRenderer. I am running DetectLeaks, and the material count goes off the charts only a few seconds into the scene. Eventually this crashes the Editor or Player since the problem consists even after building.
These lines of code are the culprits (run in Update function)
lineRenderer.material.mainTextureScale.x = vertexCount*stretchMaterial;
lineRenderer.material.mainTextureOffset.x = Time.time*offsetMaterialSpeed;
Didn't have this problem before I installed 3.5
Any help or pointers would be greatly appreciated! Thanks
Try saving a hard reference to the material in Start or Awake, and then using that ins$$anonymous$$d of renderer.material. So, only call lineRenderer.material once, and after that use the reference that that provided for you.
Thanks syclamoth, that solved it :) Was worried I had to remove the behaviour completely
Your answer

Follow this Question
Related Questions
Memory leak when running Process() 0 Answers
Memory Allocation Continues to Grow? iOS. 4.6.3 0 Answers
Memory Leak Help 2 Answers
Mesh Destroy After an Editor Stop 0 Answers
EXC_BAD_ACCESS (SIGABRT) from Unity::Material::CreateMaterial 0 Answers