Unity 5.5 - Can ParticleSystem startLifetime but cannot read it

I use to use this code:

ParticleSystem m_System = GetComponent<ParticleSystem>();
m_System.startLifetime = startValue; //Write
float read = m_System.startLifetime; //Read

But after updating to Unity 5.5, Unity deprecated startLifetime.

I now have to do:

ParticleSystem m_System = GetComponent<ParticleSystem>();
ParticleSystem.MainModule main = m_System.main;
main.startLifetime = startValue; //Write

The problem is that I can’t read main.startLifetime.
I can’t do this:

float read = main.startLifetime; //Read

I get the error:

Cannot implicitly convert type ‘UnityEngine.ParticleSystem.MinMaxCurve’ to ‘float’

What’s the equivalent of reading ParticleSystem.startLifetime as a float?
What’s the equivalent of reading ParticleSystem.startSize as a float?

I also used to have another Particle code that looks like this:

ParticleSystem.startSize *= myMultiplier

I noticed startLifetimeMultiplier in ParticleSystem.MainModule.

How should I translate this? Thanks.

Oops. Title is supposed to be “Can set ParticleSystem startLifetime but cannot read it”

It seems like you want to read the constant value - but it would depend on what type of curve it is.

Thanks for your reply. How about the rest of the question? ParticleSystem.startSize*= myMultiplier…?

Documentation is your friend :slight_smile: