[HOWTO] How To: Show UI On Top

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 22871
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Show UI On Top

Post by Tony Li »

If you're using world space UIs such as overhead speech bubbles, you may want them to appear on top of everything else, even if something in world space is technically in front of the UI.

One way to do this is to use a separate UI camera.

1. In the Hierarchy, right-click on MainCamera, and select Camera. This will add a new child camera. I named it UICamera and configured it like this:

Image

(For 3D scenes, you don't set Projection to Orthographic.)

2. Then inspect the MainCamera, click the Culling Mask dropdown, and deselect UI:

Image

The MainCamera, which has a Depth of -1, will first draw everything except objects on the UI layer. Then the UICamera, which has a Depth of 0, will draw only objects that are on the UI layer. (Any depth numbers are fine, as long as the UICamera's depth is higher.)

3. Set your UI's layer to UI.
Post Reply