First off, If you do not already have NGUI up and running, create a simple 2D UI, as we will copy some of the existing components.
Here's what you do:
- Under UIRoot, copy the camera, and place it under your main camera (as a child)
- Set it's position and rotation to 0-0-0 (So that it has the same as your main_camera)
- Maybe rename it to something like HUD_Camera
- Create a new Layer - Let's call it "HUD" (or whatever you like)
- Set the Culling mask of the HUD_Camera to HUD (and HUD ONLY!)
- Copy the UI_Root and put it under the object you want to have HUD text above (as a child)
- Set it's Layer to "HUD"
- Position it so that it hovers above the GameObject
- Now, create your HUD-UI (Labels, Sprites, whatever you want)
That's basically it. It's now a 3D HUD. Which means if you are behind it, it's backwards, if you are above it, it's invisible. To change this, apply this Script to your UIRoot:
1: using UnityEngine;
2: using System.Collections;
3:
4: public class HUDFaceCamera : MonoBehaviour
5: {
6: void Update ()
7: {
8: transform.LookAt(Camera.main);
9: //Attention: This only works if your
10: //HUD_Camera is in the same position
11: //as your main_camera
12: }
13: }