OSVR / OSVR-Unity

Package for authoring OSVR experiences with Unity.
Apache License 2.0
99 stars 38 forks source link

Unity Canvas with OSVR #103

Closed wdegraaff closed 8 years ago

wdegraaff commented 8 years ago

Hi, I have a problem with using OSVR and canvas together in Unity. The problem currently is that canvas needs a camera target,which will be only one camera in OSVR. Compared to, for example Gear VR, where there are two camera's, meaning you will need to create two canvasses for both camera's. The problem is that when I render GUI elements to the canvas, on the Gear VR this shows properly on both eyes (one canvas left and one canvas right), however, since I have only one camera on OSVR, the GUI elements are shown in the middle. This way both eyes will not see the elements correctly. What can I do to resolve this problem? I can only think of rendering all GUI elements twice on the same canvas and one set of elements positioned on the left side and one set of elements on the right side, however, there must be a better way to solve this problem.

DuFF14 commented 8 years ago

Hello, I haven't developed for GearVR, but I assumed it would be identical to Oculus PC development, where VR support is built into Unity and there is one camera in the scene.

In OSVR, the number of cameras in the scene depends on the number of eyes in the server config file. Most of the time, there will be two cameras, created at runtime, and a third camera attached to the VRViewer (the "head") which doesn't render but serves as the "MainCamera" in the scene for other objects to reference. If you see one camera, either the scene isn't running, the server isn't configured for two eyes (by default, it is configured for the HDK which has a two-eye configuration), or there is an issue with HMD connection.

Nonetheless, I think you should take a different approach to UI. Rather than creating one canvas per eye, create one 3D UI canvas and put it in your environment. Then it becomes a 3d object in the scene just like any other. See the Unity VR Samples project for an example: https://www.assetstore.unity3d.com/en/#!/content/51519

DuFF14 commented 8 years ago

We recently released an OSVR version of the Unity VR Samples project linked in the previous comment. Please see the gui examples there: https://github.com/OSVR/Unity-VR-Samples Closing this issue.