- I have a sprite in the center of my screen.
- The sprite is in world space, but sometimes it is obscured.
Occasionally, the sprite will collide with objects that it gets too close to and will be obscured.
There are several options for rendering a sprite in front of everything else in your scene.
Firstly, you can use two cameras: one for UI and another one for the "normal" scene.
Furthermore, you could use a shader that has a ZTest of 'always' (SL-CullAndDepth). Download the Unity shader source by clicking the Downloads drop-down > Built in shaders, and add that ZTest statement to the sprite shader.
- You can find the source for all Unity built-in shaders at the Unity download archive. Make sure you download the built in shaders for the version Unity version you are using.
Another option is to put your UI on a canvas set to screen space - camera and then set the sorting layer to UI. You can learn about the different canvas render modes and some of their uses at the Unity UI Docs - Canvas
Finally, you can overwrite the material's render queue value using Material.renderQueue. The value for Overlay is 4000. Using this value should make the sprite render on top of everything.
For more details, please see the following pages from our manual: