Search Unity

Enabling emission

Discussion in '5.3 Beta' started by mihakinova, Oct 27, 2015.

  1. mihakinova

    mihakinova

    Joined:
    Jan 6, 2015
    Posts:
    85
    This may have a very simple solution but here it goes...

    In Unity 5.2 you could enable and disable the ps emmision by doing:

    Code (CSharp):
    1. ps.enableEmission = true;
    2. ps.enableEmission = false;

    Now, in 5.3 this is deprecated, and we have ps.emission.enable. However, since it's a struct property you cant directly set the "enable" so you would have to do:

    Code (CSharp):
    1. ParticleSystem.EmissionModule em = ps.emission;
    2. em.enabled = true;
    3. ps.emission = em;
    However, since the "emission" has a private setter, there is no way to set or get it.

    Am I missing something or is there no way to enable or disable the emission?
     
    rikey likes this.
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    1,144
    Hi,

    You don't need line #3, but otherwise your new code is correct and should work.
    We don't like that users must cache 'em' in a separate variable first, but we haven't found a solution to that yet.
     
    ireth_86 and Andy-Korth like this.
  3. mihakinova

    mihakinova

    Joined:
    Jan 6, 2015
    Posts:
    85
    That did the trick, thank you!

    But this same method does not work with, say, transform.position, I still have to re-set it to the cached variable. Is there a reason for this?
     
  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    1,144
    Not really a good one.. basically, we tried to expose the particle API in a way that caused no GC usage, and this is the end result. Hopefully we can improve the syntax in a future version - I'd really like to just say 'ps.emission.enabled = true;' without caching the other variable.
     
    KUFgoddess, Orrib, domkia and 4 others like this.