How to Render UI GameObject on Top of Everything in Unity3D

Rendering an object on top of everything is sometimes required in Unity3D. For example, you may have a 3D UI with a health bar that you want to display on top of everything, or a 3D UI menu that should be rendered above all other objects in Unity3D. Fortunately, there is a simple and efficient way to accomplish this by adding an additional camera that will render your specific game object or User Interface (UI) layer on top of everything else.


To achieve this, follow these steps (you can also watch my tutorial here):

  • Create a specific layer with an appropriate name such as "TopUI" or "TopObjects".
  • Assign this layer to the game object(s) that you want to render on top, such as the UI game object.
  • Create a child camera game object under your main camera.
  • Ensure that the child camera game object has a position and rotation of zero.
Set the child camera's Depth Flags to "Depth Only" and under Culling Mask, select only the layer you created for your top UI (as mentioned in the first step). Go back to your main camera and uncheck the layer from the culling mask that you created in the previous step.

Render on top of everything in Unity





Post a Comment

0 Comments