Search Unity

Unity 5.5 - Can ParticleSystem startLifetime but cannot read it

Discussion in 'Scripting' started by hangemhigh, Dec 30, 2016.

  1. hangemhigh

    hangemhigh

    Joined:
    Aug 2, 2014
    Posts:
    56
    I use to use this code:

    Code (csharp):
    1.  
    2. ParticleSystem m_System = GetComponent<ParticleSystem>();
    3. m_System.startLifetime = startValue; //Write
    4. float read = m_System.startLifetime; //Read
    5.  
    But after updating to Unity 5.5, Unity deprecated startLifetime.

    I now have to do:

    Code (csharp):
    1.  
    2. ParticleSystem m_System = GetComponent<ParticleSystem>();
    3. ParticleSystem.MainModule main = m_System.main;
    4. main.startLifetime = startValue; //Write
    5.  
    The problem is that I can't read main.startLifetime.
    I can't do this:

    Code (csharp):
    1.  
    2. float read = main.startLifetime; //Read
    3.  
    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:

    Code (csharp):
    1.  
    2. ParticleSystem.startSize *= myMultiplier
    3.  
    I noticed
    Code (csharp):
    1. startLifetimeMultiplier
    in
    Code (csharp):
    1. ParticleSystem.MainModule
    .

    How should I translate this? Thanks.
     
  2. hangemhigh

    hangemhigh

    Joined:
    Aug 2, 2014
    Posts:
    56
    Oops. Title is supposed to be "Can set ParticleSystem startLifetime but cannot read it"
     
  3. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
  4. hangemhigh

    hangemhigh

    Joined:
    Aug 2, 2014
    Posts:
    56
  5. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539