Search Unity

Sorting order of particle systems through scripts for top down 2D

Discussion in '2D' started by TruffelsAndOranges, Nov 24, 2015.

  1. TruffelsAndOranges

    TruffelsAndOranges

    Joined:
    Nov 9, 2014
    Posts:
    92
    Hey!

    I am making a top down 2D game. I need the particle systems sorting order (or even better, particles sorting order) to change when the particle system is moved. I cannot find ANY way to do this through script. It seems as if the sorting order is not exposed to the programmer! Anyone found a work around?
     
  2. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Hi

    Use GetComponent<ParticleSystemRenderer> () on the GameObject that has the particle system and set the sortingOrder or sortingLayerId as you would for a renderer.
     
  3. TruffelsAndOranges

    TruffelsAndOranges

    Joined:
    Nov 9, 2014
    Posts:
    92
    Thank you! This should be added to the documentations somewhere. Had a really hard time finding that, and it's far from obvious seeing how everything else in Unity is designed.