Before 5.5 particle system variables could be accessed via ParticleSystem and were read/write. Now they're accessed via ParticleSystem.MainModule and thus a lot of code has become obsolete. The API Updater has not been able to fix most of the issues. I've read through the new documentation but I can't figure out how the new variable types are supposed to be used. For example in JetParticleEffect.cs this line causes a warning:
// set the original properties from the particle system
m_OriginalLifetime = m_System.startLifetime;
The warning states: 'ParticleSystem.startLifetime' is obsolete: 'startLifetime property is deprecated. Use main.startLifetime or main.startLifetimeMultiplier instead.'
I've tried the following:
m_OriginalLifetime = m_System.main.startLifetime;
// error: Cannot implicitly convert type 'UnityEngine.ParticleSystem.MinMaxCurve' to 'float'
I believe the answer has something to do with the minMaxCurve constant variables as this compiles:
m_OriginalLifetime = m_System.main.startLifetime.constant;
But there is almost no explaination in the docs. Can anyone shed some light on this?
Also, where do the new multipliers fit in? I assume where previously you could do this:
particle.startSize *= myMultiplier
... you should now do this?
particle.main.startSizeMultiplier = myMultiplier
				
                        
particle.startLifetime:
First of all, what Unity did in Unity 5.5 was to add new futures to the
ParticleSystem. They also exposed someParticleSystemAPI that was hidden before.ParticleSystem.MainModule.startLifetimeis now a type ofMinMaxCurveinstead of float likeParticleSystem.startLifetime.By doing this, you are now given more options such as modifying the
startLifetimeas a curve.Reading or writing to
ParticleSystem.MainModule.startLifetimedepends on the value ofParticleSystem.MainModule.startLifetime.modewhich is set through the Editor or via code.The default value of
ParticleSystem.MainModule.startLifetime.modeis ParticleSystemCurveMode.ConstantSo your
m_OriginalLifetime = m_System.main.startLifetime.constant;is fine.If
startLifetimeis dynamically or randomly changed to another mode during run-time, then you will have to do something like this:particle.startSize:
The-same thing apply to
particle.startSize. Theparticle.startSizeproperty is nowm_System.main.startSize;Although you can't do
m_System.main.startSize.constant *= myMultiplier;because your old code wasparticle.startSize *= myMultiplier.You need to get
m_System.main.startSize, modify it then assign the modifiedm_System.main.startSizeback tom_System.main.startSize.particle.startSize *= myMultipliershould be:Then, what are
particle.main.startSizeMultiplierandparticle.main.startSizeused for?This two variables can also be used to change
startLifetimeandstartSize. It's main advantage is that it is very efficient. It does not not require that you make a copy ofMinMaxCurvelike we did above, in order to changestartSizeorstartSizeMultiplier.and
Use them if your
ParticleSystem.MainModule.startLifetime.modeis constant. This will to change the overall lifetime multiplier or the the overall size multiplier efficiently.Changing Color and Color Modes
Color:
There is an implicit operator that lets you use:
but
startColoris not actually type ofColor. ThestartColorvariable is now a type ofParticleSystem.MinMaxGradient.This is how you should be changing the particle
startColor:Gradient:
Random Between Two Colors:
Random Between Two Gradients:
Random Color: