I would like to fix text to the screen for an Oculus Rift in Unity. The text should say something like "get comfortable and then press any key". It seems like OVRGUI.StereoBox should work for this and I've tried to copy an example I found on Github, like so:

public class TargetScript : MonoBehaviour {
    void OnGUI() {
            Debug.Log("Drawing Recenter dialog.");
            string loading = "LOADING...";
            OVRGUI guiHelper = new OVRGUI();
            guiHelper.StereoBox(300, 300, 300, 300, ref loading, Color.white);
            Debug.Log("Stereo Box should be visible.");
            Debug.Log (guiHelper);

The log messages indicate that this code block is definitely being hit, but no text is visible on screen.

What am I doing wrong?


When I had to do this in the past, I just parented the UI canvas for the text to the Camera. This should work for the first-party support for the Oculus available in Unity 5 now.

Alternatively, if you're using a plugin like the OVR plugin or similar, you should still be able to track down a suitable parent for the text's canvas.

e.g. The CenterEyeAnchor for the OVRCameraRig
(see https://developer.oculus.com/doc/0.4.4-unity/class_o_v_r_camera_rig.html)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.