- Home /
How can I draw a ParticleSystem over the new Unity 4.6 UI?
I want to play a particle system (of 2D sprites) in the UI I am currently making, using Unity 4.6 beta's new UI system. The UI has a solid colour background so I need to somehow modify the draw order such that the particles play on top, but I am not sure how to do this.
Here are some things I've tried:
Changing the Z position in the inspector.
Changing the Layer in the inspector.
Changing the Sorting Layer programmatically via an attached script.
Parenting the ParticleSystem to a Canvas and overriding its Sort Order.
Changing the shader used by the ParticleSystem.
Nothing seems to work so I must be doing something wrong. Does anyone know how to make the ParticleSystem draw in front of the UI?
I haven't actually tried 4.6 yet but I didn't see camera depth on that list. How does the 4.6 gui handle camera depth?
Render your particle system to a camera that has a higher depth than the one rendering the gui.
Answer by Oris · Mar 04, 2015 at 02:40 PM
In Render Mode of your Canvas, place ScreenSpace - Camera with Main Camera in Render Camera.
not working .still particles hide behind the Canvas
It works for me. $$anonymous$$ake sure your SortingLayer of the ParticleSystem(in the Renderer pulldown) is higher than Canvas's one.
Answer by atr0phy · Mar 28, 2015 at 04:15 AM
It's actually pretty simple once you get it figured out. There's a few different approaches you can take; here's one:
Create new scene.
Set camera projection to ortho. Leave its position at 0, 0, -10.
Create your canvas, add some elements if desired.
Set canvas' render mode to World Space (this makes it easier to anchor particle systems to canvas elements, since canvas element positions are all relative.)
Set canvas' position to 0, 0, 500. Don't worry, the canvas won't shrink. I'm setting its posZ to 500 since my particle system ejects particles along all 3 axes [see image below.] This will prevent particles from being accidentally thrown behind the canvas and obscured.
Jump back to the camera, increase its Size property until it encapsulates the entire canvas in the game view.
Create particle system, set its position to 0, 0, 0.
Increase Start Size of particle system, since it may be too small to be seen easily. I set mine to 100.
Test your scene. If the particles are being hidden shortly after spawning, or if you're having any other visibility issues, set the viewport to 3D to help you get your bearings. Be mindful of the rotation of your particle system, especially if you're throwing particles along a specific vector.
Here is a gameview screenshot of my final result:
not working .still particles hide behind the Canvas
Answer by lilboylost · Dec 14, 2014 at 04:23 AM
Canvas Render mode to "Screen Space-Camera"
Add Sorting Layer Keep all sorting layer at order in layer "default" "0" Animation canvas at higher number.
This has worked for me. It does not work if any canvas have order number non-zero(probably a bug)
Answer by U_Ku_Shu · Aug 08, 2016 at 07:25 PM
Particles will be foreground to other UI element's if you do the following steps:
Also you can use this addon:
It works for me in 2018.4.8f1. $$anonymous$$ake sure you're creating a sorting layer and not a custom User Layer. Note that this does not render over your canvas if it's set to Screen Space - Overlay, only if it's set to Screen Space - Camera. And your particle system must not be under your UI Canvas hierarchy.
You need to change the render mode of canvas to screen-space camera.
Answer by Kiwasi · Nov 25, 2014 at 05:27 PM
A world space canvas works. Not ideal, but it works.
It doesn't renders the shaders in particle tab. If you change the material to transparent/unlit cut out it works. I have Image(UnityEngine UI) as BG and i want to show particles over the BG.
Your answer
