Follow

Is there a simple way to make a sprite render in front of everything in the scene?

Symptoms
  • I have a sprite in the centre of my screen
  • The sprite is in world space, but sometimes it is obscured.
Cause
 
Occasionally, the sprite will collide with objects that it gets too close to and will be obscured.
 
Resolution
 
There are different 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 and add that ZTest statement to the sprite shader.
  • Another option is to put your UI on a canvas that is set to screen space - camera and then set the sorting layer to UI.
  • Finally, you can overwrite the render queue on your material. The value for Overlay is 4000
 
More Information
 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.