- Home /
Draw texture directly on Oculus screen
I want to draw a texture directly on the Oculus Rift screen (or at least for the texture to be shown on the entire camera). I've been trying to draw the texture using "OnGUI", but I later discovered the command is not supported in VR:
public void OnGUI() {
GUI.DrawTexture(new Rect(0, 0, Screen.width/2, Screen.height), texture);
GUI.DrawTexture(new Rect(Screen.width/2, 0, Screen.width/2, Screen.height), texture);
}
Is there any other command or trick to draw the texture in front of the user camera?
Answer by stuey0016 · Oct 10, 2017 at 11:58 AM
This technique actually isn't supported in Unity. There are no commands for drawing directly to the screen. It really does mess with your eyes to see any part of the world move with your head. See the section entitled Non-digetic in this link:
https://unity3d.com/learn/tutorials/topics/virtual-reality/user-interfaces-vr
UI in VR projects should be a part of the world. If you need a pause menu, affix a Canvas in front of the camera and give it a Render Mode of World Space. I have a project that supports both VR and standard monitors. I reuse the same Canvas for both UI's and switch the render mode using script at runtime.
If you need a HUD, try building it right into part of the player object (for instance...a dashboard in a car or spaceship). It takes a little more management, but it's also a cool looking effect in the VR world!