- Home /
Help! Canvas element cannot be seen in Oculus. (Unity 5.2.3) (C#)
Hello everyone,
I dearly miss my GUI.Button()s right now, because I'm having to learn UI all over again for my new project. And UI was about the only thing I fully understood!
I have a scene which I have set up using Oculus Rift and its default OVRPlayerController which contains the scene's MainCamera, with a culling mask set to Everything and depth set to 0.
I also have a new Canvas in the scene which is active and uses Screen Space - Overlay and Pixel Perfect. Inside of this canvas is a single element, a Text I am calling DoorOpenPrompt which simply says "Press A to Open Door". I have a Canvas Group assigned to this which I will be altering in a script, changing the alpha based on whether I have come into contact with a door Trigger.
However, even with the Alpha defaulted to 1 and Interactable and Blocks Raycasts defaulted to true on my DoorOpenPrompt's Canvas Group, the Text does not display in my game screen nor in my Oculus' rendering of the game screen.
All of my UI/Canvas elements are on the UI layer, which is being rendered (along with Everything) by my Main Camera, which is part of the OVRPlayerController's OVRCameraRig.
What am I missing? Why is nothing displaying at all?
Adding a default Button at the center of the canvas also does not display in Game mode, neither on screen nor in the Oculus.
Here is an image of a scene I made from scratch in a $$anonymous$$ute with the level's basic geometry, a standard Empty Game Object with a Character Controller attached and the $$anonymous$$ain Camera parented to it. The canvas settings and the text displayed are not altered, save for the text and the text's appearance. (No Oculus-specific things in the scene.)
The text shown in the Scene window does not display in the Game window, nor in the Oculus (which actually still works to view the scene, even without the OVR kit).
Also, as an aside, Unity has built-in Oculus support as of 5.x so you don't need any OVR*** stuff anymore. Any default camera will work as long as you check Virtual Reality Supported in the Player Settings.
Answer by ZefanS · Dec 03, 2015 at 12:53 AM
You're not actually doing anything wrong with the GUI per say, but using the traditional GUI with the Oculus Rift is somewhat equivalent to trying to glue some text to the player's eyeballs - it just doesn't really make sense, because there's no "screen" in the traditional sense. Thus when you have virtual reality mode activated all on-screen GUI stuff gets deactivated automatically. Designing GUIs in VR is actually somewhat different than designing a traditional GUI because it will have to exist in the world as opposed to on top of the world. I have yet to try, but as far as I know the built in GUI system does allow you to create GUI elements that exist as part of the 3D scene. This type may be view-able with the Rift. Otherwise, I would highly recommend the package available in this thread. I haven't tested it with the most recent versions of Unity / Oculus plugin, but it worked for me in Unity 5.1 at least.
Hope this helps.
I did a little test and setting your Canvas's render mode to World Space will allow it to be seen in the Rift. All you need to do then is scale and position it correctly and then make it a child of the camera to have to appear like a traditional GUI. It will however, be occluded by objects in the scene. $$anonymous$$aking an interactive GUI will prove more challenging, but you could do things like use a Raycast to activate buttons with the user's gaze, or create a custom mouse cursor as a UI.Image and a script to control it. There are lots of possibilities. GUIs are certainly one of the areas that have plenty of room for innovation in VR.
Note that the package linked above takes the latter route of implementing a custom mouse-controlled cursor.
Here's some relevant info from Oculus: https://developer.oculus.com/blog/unitys-ui-system-in-vr/
Your answer
Follow this Question
Related Questions
How to Render Unity UI Canvas in between two 3D Objects? 0 Answers
[VR] How to display a canvas with Oculus 5 Answers
Screen Space - Camera Bug (Buttons does not work) on Unity 2017 0 Answers
New UI(=uGUI) depth problem with particle 0 Answers
How to set the UI Text position to be relative to his "grandfather" prefab 0 Answers