Unity 5.1 has integrated VR, its in the Build Player Settings as a checkbox. I want a startup scene that is not VR, then when the user starts it enables the VR camera. How can I do that?
with the checkbox checked put āVRSettings.enabled = false;ā in startup and VRSettings.enabled = true; when you want to enable VR mode.
You could do what Lennart messaged above or you could change the VRSettings.loadedDevice to none and Oculus depending on which mode you want. This can be changed at runtime, but in the Editor it will force you out of play mode. In standalone builds it will not close the window or revert the scene. It continues from where you currently are in your scene.
This is working in 5.1.0p1. Unfortunately there was a bug with this in previous versions, so you will need to update to the latest patch if you wish to use this.
thanks for the responses. The VRSettings.enabled is working fine for me.
@anon_62935208 , what are the possible values for device? i heard that GearVR has been added as a device but that would be Android, versus Oculus is just desktop. Are there any plans to include Cardboard natively for Android and iOS?
This list of devices can be found here: http://docs.unity3d.com/ScriptReference/VR.VRDeviceType.html
GearVR is included in the Oculus device type. So when you choose DeviceType oculus. You will be able to deploy to Android and run on a gearvr.
We do have plans to add additional native support for more Plugins like Cardboard. As a side note (we havenāt tested this) it may be possible to use DeviceType stereo to make Cardboard apps. However, it would be more appropriate to use the cardboard plugin.
The cardboard Unity asset includes distortion code for lens correction. This need to be done. A standard stereo device type will not look optimal. The distortion code also varies for the different cardboard lenses. v1 and 2
What about OpenVR / SteamVR? For now, I prefer their SteamVR plugin (and would actually prefer to have the native Unity integration be designed much more like that). But eventually, it would be nice to have it all integrated natively into Unity.
It also seems that sometimes, the native integration conflicts with the SteamVR plugin: I just recently had the case that I had āVirtual Reality Supportedā switched off but it looked as if both was trying to render to the HMD with quite a bit of odd flickering going on ⦠but that could also have been something else - I just never saw that when using the SteamVR plugin in Unity 5. Iāll probably add VRSettings.loadedDevice = VRDeviceType.None; in startup just to be sure.
Another really important one is Sony Project Morpheus, of course.
Iām working with the Note 4 / Gear VR in 5.1.2. If you check VR Supported in the Player Settings, the Android Device asks you to place your phone in the Gear VR before the game begins⦠What if you have some levels in VR and some in Non-VR, and want to start in a Non-VR menu?
My test today was an .apk with VR Support unchecked in the player settings. The user starts in a non-VR level. When the user loads a VR level, I have a script in said VR level where the Start() function sets VRSettings.enabled = true and also sets VRSettings.loadedDevice to VRDeviceType.Oculus.
However, once I start my VR level and this code executes, I do not see dual cameras rendering. Additionally, inserting my phone into the Gear VR once my VR level is loaded will launch the Oculus VR Home app. Prior to inserting my device into the Gear VR when my VR level loads, my logcat actually shows the same OVR reference errors from the Android Personal Edition bugs that Ed Unity and I worked through in versions before 5.1.2
Maybe itās not a bug since I could understand the argument that my implementation is an edge case, but⦠Repro steps:
VR supported unchecked.
Scene 0: Scene 0 is non VR, using new Unity GUI elements to load a VR-enabled level (call it Scene 1)
Scene 1: When Scene 1 loads, code is executed to enable VR and set device type = oculus.
Symptom - No dual camera rendering. No Prompt to insert device into Gear VR. When the user inserts the device into the Gear VR voluntarily, the Oculus VR Home App launches.
We are planning to integrate more than just Cardboard. Like you said, eventually it would be nice to have everything integrated natively. The ground work has been done to make adding additional plugins easy. We are still adjusting the integration to better suite how you and other users feel is the best way work with VR in Unity. We are taking all advice into consideration and we thank you for your contributions to making the VR integration as best as possible. You should be seeing some changes soon based on everyoneās feedback so far. A little bit more work still needs to be done for Projects settings with regards to selecting different device types. Once that work is in, we can start adding additional devices like you mentioned.
The prompt to connect to the Device is actually done in the Oculus plugin. We have no control over the prompt. GearVR applications cannot be partially VR and partially non-VR. As in you cannot switch into or out of GearVR at any point in the application. It either is a GearVR app or it is not. So being able to switch VRDeviceType with GearVR shouldnāt actually be possible.
Thanks for the response, Ed Unity. I guess Iām looking at making two separate yet companion apps (which is annoying but not the end of the world).
Application.persistentDataPath is the right place for me to share something like a flat JSON file where the two apps could share data about one anotherās progress, correct?
You might be able to use persistentDataPath, but Iām not sure if two separate applications would return the same path. If they do, then you should be able to share the progress through that location. Iāve actually never run into this situation, so I donāt know what the best solution on Android would be. Try asking on the Android Forums just to be sure.
Do you know if there are any plans to support this functionality in the future?
Thank you! Thatās great to hear!!!
Thatās pretty annoying. I wanted players to use VR if they have a headset, now Iāll need to make a separate app and sell it separately, which will not please my player base.
This does not work well , please see my post in the VR forums, The problem is the app launches to VR and then only kicks out of it and into regular play. That is an unacceptable user experience. I need the app to launch smoothly into regular game play. This is for oculus.
Hi,
I was wondering if changing between VR and Non-VR is still not support on GearVR.
Iām trying to start an app with Non-VR and then activate it via script but even when I use VRSettings.enabled=false and VRSettings.loadedDevice=VRDeviceType.None the first thing the apps does is asking you to put the pone in the GearVR so then you see the Non-VR app through the glasses and if I get the pone out the app just closes automatically.
So basically I would like to know if this is something doable or it is imposible so I donāt keep trying to do something that I wonāt get done.
Thanks!
Unlike daydream or cardboard, for gear vr Oculus does not allow you to do this. Perhaps one day theyāll change their mind, you could try contacting them. Unity isnāt the party holding this up.
Thanks for the answer!
Iāve left my comment there too just in case it helps.
Iād love to be able to do this, personally. In my case my goal is to have separate scenes where I can have a VR scene with the same objects, but another scene dedicated just for testing/debug which is more isolated where I donāt have to enter VR. For now, Iām limited to manually going into Edit ā Project Settings ā Player ā XR Settings in order to enable/disable VR so I can have more direct control (or if my laptop isnāt currently connected to my eGPU/Vive).
ĀÆ_(ć)_/ĀÆ