Unity5.6.0f3, Unity Native Cardboard: How to add an onscreen button for enable/disable vr mode?

I was still using unity googlevr sdk 0.8.1 because that is the only version that I can customize Cardboard UI element.

Now I just tried newest Unity 5.6.0, and also removed all cardboard sdk related files in the project,
and now i have this problem:

How to add an screen overlay ui when in the vr mode?

Because I had an custom ui overlay, so that I can enable/disable cardboard view whenever I want.
And now I don’t know how to do it, because ui overlay won’t show on screen.

And I need more information about the following:

  1. Does VRSettings.enabled also works for native unity cardboard and daydream? GearVR too?
  2. If I enabled all vr mode, like cardboard/daydream/gearVR, if I deployed it on a device that support those, can I use them all at same time? For example switch between cardboard mode/daydream mode/ gearvr mode.

Hi,

I have a similar problem.

I had a project running with Google VR SDK 0.9.1 under Unity 5.4.2
I used to toggle VR mode on and off programmatically (my app had a login screen before entering VR mode) and it worked fine.

Now with the latest Google VR SDK 1.30.0 and Unity 5.6.0f3, toggling VR mode no longer works.
When entering VR mode, I get a full black screen.
I seems that the native VR support of Unity 5.6.x disables the ability to toggle VR mode as per the code documentation (see screenshot).

Can someone from Unity or Google confirm this?
Is there an alternative to toggle VR mode?

Cheers,

3022488--225832--VRModeEnabled.png

GvrViewer source does not run on-device in Unity 5.6 - please use a combo of VRSettings.enabled, VRSettings.loadedDevice, and LoadDeviceByName. The GVR device names are “cardboard” and “daydream”, all lowercase.

@cdytoby What is your use case for customizing the UI layer? This is now controlled from VrCore, for UX reasons.

We recommend updating to Unity 5.6.0f3 and v1.40 of the GVR Unity SDK when it is released, because we will no longer support Unity versions older than 5.6 as of v1.50.

Wow, Official Google Employee? Thanks for the reply, I’ll state our full requirements here.

  1. We need a vr mode and non-vr mode switch button, so In former version I added Screen Overlay Canvas in Unity, and added a button at bottom right to switch both modes.
    In order to make button click work, I customized the input module, modified from cardboard sdk, I also took some codes from unity ui source code which are open sources in bitbucket.
  2. The back button on the top left side must hide. We have our own methods to handle back button.
    In non-vr mode, we have some action buttons on the top left side.
    In vr mode, we have world canvas ui that contains the same set of the action buttons.
  3. We need to play 3D videos in the app. That means left eye and right eye should be able to display different contents. Now Unity Camera can also do this, so this shouldn’t be a problem.
  4. iOS cardboard support. Last time we checked, there is an issue on transition screen or something when the ios device is not in landscape state, and there are also issues when user switch from non-vr to vr, vr view is shrinked. I don’t know if the unity 5.6 have the same issue. But it was there in cardboard sdk around 1.1 version.
  5. The most perfect awesome thing would be: user can switch from one to another including non-vr mode, cardboard-vr mode, daydream-vr mode, and gear-vr mode, if the android device supports it. (It may be too hard, so it’s not important right now.)

It would be great if Unity official or google official can provide some more information on this.

1 Like

When our App provides both Non-VR-Mode and VR-Mode and we can switch between these modes it is not neccessary that the app starts in Landscape-Mode. So:

  1. When we enable “Virtual Reality Supported” in the PlayerSettings the App is forced to start in LandscapeLeft-mode.
    Please remove this, too. (It gets handled when we enable VR-Mode.)

Adding developer backing on these
“1. We need a vr mode and non-vr mode switch button, so In former version I added Screen Overlay Canvas in Unity, and added a button at bottom right to switch both modes.
In order to make button click work, I customized the input module, modified from cardboard sdk,
2. The back button on the top left side must hide. We have our own methods to handle back button.
In non-vr mode, we have some action buttons on the top left side.
In vr mode, we have world canvas ui that contains the same set of the action buttons.”

Haven’t stepped up to 5.6/1.4 for our product yet due to these limitations. I understand Google’s desire to maintain a certain level of Quality on the UX, but removing customization from developers is not the way to do it.

Presently migrating from 5.5/1.2 up to 5.6/1.4 ‘breaks’ our applications ability to start in non VR mode, call VRSettings from 2D screen (settings, req’d privacy notice, etc) to starting VR mode (VRSettings.enabled, and etc) app dumps after completion of VR loading. Forcing users to complete all settings and notices inside VR mode…

Google, can we bring back the back end customizations for Developers. Honest, we know (mostly) what we’re doing, don’t go all Apple on us…

2 Likes

About allow us to darken/hide/remove those buttons from the UI (That do nothing other than cause problems ) there was a lot of complains about it in the github and they just ignored it.
https://github.com/googlevr/gvr-unity-sdk/issues/266
They said that people are not capable to exit the app without it (Makes no sense at all). See also that the HMD configuration will be done once (first time when you get a new headset) but it icon is mandatory in all your apps, all the time! Great UX design google have for it don’t you think?
Hope someday they take sometime to listen the developers a bit more.

2 Likes

Making an internal button assigned to Application.Quit seems to have worked for the past 5 years or so for the rest of the development world, across just about every platform…

And Google “If an application hangs preventing the user from using internal controls” this will also lock up your on screen UI as well. In which case, the user is going to Have to touch the device… This isn’t a difficult concept

We also need to start the app in Non-VR mode which we had in previous Unity version. Now in 5.6 is starts in VR mode , then we immediately switch back to non-VR mode and that looks getho

1 Like

Have you tried adding “None” as the first element in VR settings in the player? That might do the trick

I’ve also been trying to setup “an onscreen button for enable/disable vr mode”.

Using 5.6.0f3 and GVR v1.40 on a Note4: if I “VRSettings.LoadDeviceByName(”“);” and/or “VRSettings.enabled = false;” the gyro just returns 0.0.0 from both Unity VR and GVR (InputTracking.GetLocalRotation and GvrController.Gyro) so I cannot rotate the camera view in non-VR mode.

This https://github.com/googlevr/gvr-unity-sdk/issues/532 didn’t work for me due to the above paragraph.

Even started looking init setting it up with “Camera.main.transform.Rotate(-Input.gyro.rotationRateUnbiased.x, -Input.gyro.rotationRateUnbiased.y, 0)” but that is drift-ey… -_-.

Open to any advice.

Edit: I guess I’ll try downgrading Unity/gvr today…

@mattSydney that does work, but from my experience when in the “None” VR mode both Unity VR and GVR (InputTracking.GetLocalRotation and GvrController.Gyro) just return 0.0.0.

Quite frankly I’m extremely dissapointed with the ‘not so thought through or tested’ native integration of the Google VR in 5.6. We’ve had nothing but problems. I know that with Unity 5.5 and GVR Unity SDK v1.40 we had none of the problems in 5.6, namely we could:-

  • Go into and out of VR as many times as we want, no problem, no crashes, no weird screen warping.
  • Overlay UI over the top of the Cardboard UI (no longer an option as per this thread)

We are running a super simple test app on a Samsung S6 running Android 6.0.1 and with Unity 5.6 native integration it crashes every time you re-enter VR after the first time you use it (and sometimes even on the first time) plus it warps the screen in a weird way after exiting VR the first time back into the app.

I filed a bug report but Unity literally just said it was a duplicate of an existing bug which has been present since Unity 5.4 and still is not fixed (Unity Issue Tracker - [Google] Switching between VR and non-VR multiple times results in out of memory problems and rendering slowdown).
Can’t really trust that though since the issue only occurs when using the ‘native’ integration present in 5.6.

All in all just a really poor experience, going from a perfectly working version in Unity 5.5 to a completely broken version in Unity 5.6! :frowning:

I ended up manually implementing Gyro navigation properly after calling “VRSettings.LoadDeviceByName(”“);” and “VRSettings.enabled = false;” and I am experiencing the same issues you identify @ProudLittlePinwheel .

  • Screen aspect is warped once VR is disabled.
  • Going from VR to non-VR back to VR consistently crashes the app.
  • GUI overlay doesn’t work in VR mode.

I’ll try Unity 5.5 shortly as you mentioned you have had no problems with this. Thanks!

1 Like

One thing I noticed is that if I set VR enabled/Disabled in the same scene it didn’t crash the device (iOS), but if, for example I had VR enabled, loaded a new scene and set VR disabled it crashed the device.

Very frustrating. I never upgrade to new version of Unity until its been out a few months because it is always bug ridden. But I required the Video Player component in 5.6, it’s been hell :(. 20 % dev, 80% f**cking around with bugs

Hello Mira Leung,

Thanks for the update on how to tackle this.

//// Ranty bit
Tiny Bit of Background: Mono is quite easy to use for those without Cardboard or other HMDs who are accustomed to holding a phone in front of them when using AR/360 video. It’s also necessary to have as a mode for any mobile VR application, in my humble opinion. When I can’t perform this switchl it is akin to denying users the audio in your product because they did not have headphones, sure the experience might not be as rich, but who remembers to take their cardboard with them everyday?I have a few experiments on the store and the users do use the mono view. Sure mono may (for now) deny mobile users of a friend hand for an additional peripheral, but the current mobile VR user space has not matured completely to embrace these, so the min spec is gaze focused, with one button input (which can be detected also by tapping the screen).
///End rant

But that small rant aside. I formerly used this simple script to switch between Stereo VR and Mono Window Mode and it worked amazingly well.

GvrViewer.Instance.VRModeEnabled = !GvrViewer.Instance.VRModeEnabled;

I followed your example in order to get this to work on 5.6 with the 1.4 package installed. A few quick notes:

Here are the links to the calls mentioned above
VRSettings.enabled
VRSettings.supportedDevices (loadedDevice is now obsolete)
VRSettings.LoadDeviceByName

Sadly, when you call this as a toggle:
VRSettings.enabled = !VRSettings.enabled;

It is turning off all VR support for the device now, including movement tracking. Not switching the video mode that the GVRviewer used to handle quite elegantly. The Mono view is also quite badly skewed. I think in order to get the functionality back I will have to somehow replicate the switch that was used in the old GVRviewer when the player switches modes. :slight_smile:

The other reason I still put the GVRviewer in the editor for a scene is the nice “Hold Alt” to move your head around functionality. I have not found the equivalent for head movement without this with Unity’s standalone solution, maybe someone else has.

I am experiencing the exact same results in 5.6 as you @Mistabullit - do let me know if you get a solution working.

I replied earlier but it was lost with Unity’s forum hack roll-back.

5.5 worked successfully as expected (thanks @ProudLittlePinwheel ), where as 5.6 is broken for the transition from VR-mode to non-VR-360-mode aka “Magic Window” aka “Mono view” with Cardboard VR support.

1 Like

Any solution for this? We just are experiencing the same and it is really frustrating…

I use this script (attached) to emulate head movement in the editor, it isn’t perfect. Sorry to the original writer of the script I forget where it came from.

Just drop onto your camera I set hold alt and mouse to move and CTRL to roll. You can set the options on the script

3063816–230278–VRMouseLook.cs (2.27 KB)

2 Likes

Thanks for the script @mattSydney - is exactly what @Mistabullit was asking for.

There is a possibility to not use the new integrated VR under Unity 5.6 : Unity 5.6.0f3 Native GVR Android / iOS enabling and disabling VR - Unity Engine - Unity Discussions

2 Likes