This may have a very simple solution but here it goes…
In Unity 5.2 you could enable and disable the ps emmision by doing:
ps.enableEmission = true;
ps.enableEmission = false;
Now, in 5.3 this is deprecated, and we have ps.emission.enable. However, since it’s a struct property you cant directly set the “enable” so you would have to do:
ParticleSystem.EmissionModule em = ps.emission;
em.enabled = true;
ps.emission = em;
However, since the “emission” has a private setter, there is no way to set or get it.
Am I missing something or is there no way to enable or disable the emission?
2 Likes
Hi,
You don’t need line #3, but otherwise your new code is correct and should work.
We don’t like that users must cache ‘em’ in a separate variable first, but we haven’t found a solution to that yet.
3 Likes
That did the trick, thank you!
But this same method does not work with, say, transform.position, I still have to re-set it to the cached variable. Is there a reason for this?
Not really a good one… basically, we tried to expose the particle API in a way that caused no GC usage, and this is the end result. Hopefully we can improve the syntax in a future version - I’d really like to just say ‘ps.emission.enabled = true;’ without caching the other variable.
7 Likes