Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
isabelringing's avatar
isabelringing
Honored Guest
10 years ago

Help with different GUI render modes

Hi everyone! I'm trying to use GUI to create text that will remain in front of the camera even when the person moves their head (sort of like the health/warning splashscreen that comes up when you first launch a game).

I'm trying to use text UI and I have to admit I'm a bit new at Unity's GUI system. I know it is most common to use the render mode 'overlay' to display text, and I have used it before perfectly in non-VR environments. However, when I click the overlay version now, the canvas does not align with the camera- and I can't change or rotate the position of the canvas, since it's in overlay mode. The canvas seems to be at a perpendicular to my camera. Is it 'aligning' with a totally different camera than the one in the 'OVR player controller'? What can I do so the text will show to the camera that the oculus actually uses?

On the other hand, I've been experimenting with the render mode camera. In this option, since you can actually set which camera to look at, I can see the text when I set it to CenterEyeAnchor. However, the text will phase through walls as if it's a solid object- I included an example of this below. Is this the right option to use, if Overlay mode is not possible? If so, how can I fix it so that the text is visible all the time, and not phase through things?

Thanks so much for reading, and please tell me what you think.

1 Reply

Replies have been turned off for this discussion
  • It usually works best to make your canvas world-space for VR (http://docs.unity3d.com/Manual/HOWTO-UIWorldSpace.html). There are several ways to prevent clipping, but watch out - if the UI is farther away from the user than the world and it doesn't get clipped, it will be uncomfortable for users to look at. One way you can achieve this is by using a separate camera for your UI. You could just make a plain GameObject with a Camera component and set the culling mask to include only the UI layer. Then make sure your UI is in that layer and exclude it from the culling mask on the CenterEyeAnchor's Camera. Another approach is to change the shaders on your UI to ignore the Z test. What I'd really recommend here is to make your UI smaller and closer to the user and push your world content further away from the user so there is no clipping with a regular world-space UI. One example is in the OVRPlayerController prefab, where we have a UI to show the FPS, latency, and a few other stats.