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 someParticleSystem
API that was hidden before.ParticleSystem.MainModule.startLifetime
is now a type ofMinMaxCurve
instead of float likeParticleSystem.startLifetime
.By doing this, you are now given more options such as modifying the
startLifetime
as a curve.Reading or writing to
ParticleSystem.MainModule.startLifetime
depends on the value ofParticleSystem.MainModule.startLifetime.mode
which is set through the Editor or via code.The default value of
ParticleSystem.MainModule.startLifetime.mode
is ParticleSystemCurveMode.ConstantSo your
m_OriginalLifetime = m_System.main.startLifetime.constant;
is fine.If
startLifetime
is 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.startSize
property 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.startSize
back tom_System.main.startSize
.particle.startSize *= myMultiplier
should be:Then, what are
particle.main.startSizeMultiplier
andparticle.main.startSize
used for?This two variables can also be used to change
startLifetime
andstartSize
. It's main advantage is that it is very efficient. It does not not require that you make a copy ofMinMaxCurve
like we did above, in order to changestartSize
orstartSizeMultiplier
.and
Use them if your
ParticleSystem.MainModule.startLifetime.mode
is 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
startColor
is not actually type ofColor
. ThestartColor
variable 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: