- Home /
Does Material.color, ParticleSystem.startcolor property clones/copies the material?
Based on the manual [1] the change to the material will make a new instance of it - "this will clone the shared material". Does the renderer.material.color creates a new clone? Or the new clone instance is only created when assigning to the material property via renderer.material = ...?
Also the same story with ParticleSystem.startColor property, does material stays the same or is it cloned when triggered?
I'm asking the question because in the game I'm working on I'm using the pooling technique on a ParticleSystem objects. When an object is required I fetch it from the pool and assign the startColor based on some game logic, before triggering Play() function. The problem is that sometimes colors simply doesn't match, perhaps because the state of the previous usage still lingers.
[1] http://docs.unity3d.com/Documentation/ScriptReference/Renderer-material.html
Answer by KEric · Mar 28, 2014 at 09:23 AM
Ok, solution... Of course I've already had it, just before I've started making my particle systems "poolable". Yes it does a copy. In my case, the issue was with startColor property, I've simply made the usage of ParticleSystem.renderer.material.color rather then ParticleSystem.startColor and that did the trick. Works flawless, finally...
Answer by OSG · Mar 28, 2014 at 09:09 AM
As I know renderer.material.color copyes material and makes new instance of it. I worked with this problem in my game.
You can read my question.
Thanks for a comment, second ago just figured the solution out