- Home /
5.4, can't set properties on ParticleSystem.EmissionModule?
Since upgrading to 5.4, I get this error in-game:
Which points to this code:
Particularly, the highlighthed line. It looks like caching the emission module to my own variable is still fine, but attempting to set a property on it, not so much. I know this whole module interface is a recent entry to the Unity scripting, but it really appears to be broken in 5.4.
I can't seem to find anything on google about this error. The error is lying, I am getting the module from a pre-existing ParticleSystem instance.
Yep - getting this on 5.5 today, despite having read and (I think followed!) the advice on changes described at https://blogs.unity3d.com/2016/04/20/particle-system-modules-faq/
Answer by tanoshimi · Dec 19, 2016 at 10:34 PM
So I don't understand the error message, the cause, or the reason why this fixes it, but I have at least found a solution in my case. It may or may not work for you depending on where/when you call ToggleParticleSystem.
Previously, I was caching the modules of the ParticleSystem in Start(), e.g.:
private ParticleSystem.VelocityOverLifetimeModule rainDropsVO;
void Start() {
rainDropsVO = rainDrops.velocityOverLifetime;
}
This worked absolutely fine until 5.5, when I started getting the same error as you. However, if I move that caching into Awake(), it works fine. Despite the fact I'm not actually doing anything with that module until much later. I figure it must have something to do with the C#/C++ interface generating a null reference which is being caught and erroneously displaying the error message, but it's certainly a bit weird!