Hi guys. I need some help with GUI
Really appreciate I'm using GUI to make an inventory .And so far I have just made a crafting system . Now I really want to add some effects when I successfully craft an item .But it seems all the particles was drawn behind the GUI . What should I do now ? Please help . Thank you
Answer by M-Hanssen · Apr 13, 2016 at 09:08 AM
You can solve this by several approaches:
Use a world space canvas and render the particles in front of the world space canvas. (Dirty solution)
Create different camera layers to render things (Best practice solution)
Create 3 camera's with the following hierarchy:
Set all camera's to "Clear flags = Depth only"
And set the depth of the camera's in the inspector as follow:
Main Camera: Depth = 0
Gui Camera: Depth = 1
Gui Particle Camera: Depth = 2
Now you have to create a layer for the GuiParticles:
And assign your particle effect to this layer.
In you inventory canvas change the render mode to "Screen space - Camera" and drag your GuiCamera to the "Render Camera" field.
Change the layer of your inventory canvas (recursively) to "UI"
Now finally set the culling masks for each camera as follow:
Main Camera: Everything BUT "UI" and "Particles"
GuiCamera: Nothing BUT "UI"
GuiParticleCamera: Nothing BUT "Particles"
You now have 3 render layers with each their own camera. All stuff marked as layer "Particles" will now be rendered in front of the "UI" layer.
hi, @$$anonymous$$-Hanssen thanks for this. but I couldn't understand this part. What you mean by recursively?
{In you inventory canvas change the render mode to "Screen space - Camera" and drag your GuiCamera to the "Render Camera" field. Change the layer of your inventory canvas (recursively) to "UI"}
if you mean by inventory canvas, where other UI elements are, I have 5 Canvasses, should I change all of them to Screen space - Camera? Also, the particle system, should it be in its own Canvas, which has GuiParticleCamera looking?
Answer by Lex_Dudya · Oct 17, 2016 at 04:00 AM
This plugin can help you https://forum.unity3d.com/threads/released-ui-particles.436611/ No cameras, work with all types of canvases. Simple usage.