I’m using 2D sprites in a 3D environment with Sorting Layers and the Order In Layer to decide the order of the elements relative to the camera.
Since the release of Unity 5.6 I had been testing the new Sorting Group component and the new Transparency Sort Mode Custom Axis. And it works!
But neither of the options works with Particle Systems because the Order In Layer of each particle cannot be set and all particles share the same Order On Layer configured in the Particle System component.
With the release of Unity 5.5 I believe that a few new variables of the Particle class were exposed and I want to ask if there are plans to include the Order In Layer or if there is a workaround that I can use (or if this cannot be done…
I think we need some method or scripts, made particles and 3d model used as normal sprites in UGUI, and could change their SiblingIndex to change depth , thanks!
Particles are all drawn in one call, so it would be very difficult for us to split each particle into its own Draw Call, for sorting purposes. It also has some serious performance implications.
The only way I can think to achieve this currently, is to set the particle system Render Mode to None, and then use GetParticles in script, to position your own sprites at each particle location. These individual sprites can then use Order in Layer however you wish.
You can also use GetCustomParticleData and SetCustomParticleData, to store ordering information, or maintain your own data in the script, as you wish.
Right now we are using the new option Transparency Sort Mode Custom Axis to order all the sprites in the scene with this configuration:
With this option we set all the Sprites with the same Order in Layer (zero) and let the sort mode take care of the sorting.
I suppose drawing the particles in one draw call doesn’t work like this but we were wondering if setting the Order in Layer of all the Particles to 0 would do anything or if something can be achieved with this.
I hadn’t thought of this workaround, I will try to implement it and see if it work for us. Thank you for your answer!
Hi, I know this thread is super old, but where you able to make this work somehow?
Thought about the same idea of rendering sprites from the particle data manually and not rendering, but can’t imagne that will perform well at all
The most pressing problem we had right now was that when throwing a projectile that left world space particles, the order of each particle system in the projectile would change all the time as particles spawned and died because it gets rendered ordered by its bounds.
For now the change we made was, using a sorting group with default values in the root of the projectile and then use orderinlayer within so that each projectile gets rendered as a whole, this doesn’t fix the issue your code fixes, but at least it behaves consistently and a bit better than before.
Will try at some point your code for some particle systems but I fear a bit that the performance will suffer a lot since this is a mobile game.
Again, thanks a lot, for the code and the quick response.