Hi all,
Apologies in advance, I’m not too sure how to word this question correctly, but here’s an example.
I want to store a snapshot of the base values of a particle emission module. In my following example, the “emissionModule” variable is always referencing the “particleSystem.emission” so if I change one, the other will change. Is there a way to break the reference so they are both unique?
I don’t think so in the general case. Playing with this briefly just now it appears that the EmissionModule, while a struct (eg a value type), isn’t really what it seems to be under the hood.
I believe it is actually the native interface mechanism to interoperate with the particle system native side engine object. Perhaps someone from Unity can correct me on this, but this assumption matches my further testing.
When you set a value in the EmissionModule what it is actually doing is finding the connected ParticleSystem and manipulating the native values directly.
If you just make an EmissionModule and transact against it, you get this error:
NullReferenceException: Do not create your own module instances, get them from a ParticleSystem instance
I’m thinking what is null is the internal “pointer” back to where it belongs, on a ParticleSystem.
All that said, I imagine you could copy the relevant values out, keep two copies of those values, then just assign them into the emission object as you want those conditions to take place.
Hey thanks Kurt! Yeah I always find particle systems really hard to deal with, it feels like there’s something complicated going on in there for sure.
I’ve just separated the relevant values out and that’s working fine.
Thanks!
Pete