Gvr-unity-sdk: Unity_5.6 + GVR_1.5 : How to switch between VR and non-VR mode?

Created on 23 May 2017  ·  15Comments  ·  Source: googlevr/gvr-unity-sdk

Hi,

In previous version of gvr sdk, I was able to open screen in bot VR and Non-VR mode using VRModeEnabled in GvrViewer class. But in current version 1.50 there is no class named GvrViewer.

Any help would be appreciated.

documentation bug

All 15 comments

Nowadays you do it through unity: https://docs.unity3d.com/ScriptReference/VR.VRSettings-enabled.html
May also be a good idea to read this thread #492

This was buggy and could not be turned off of VR mode for google cardboard when I tried 3 weeks ago. Is it fixed now?

I have used it with Gvr 1.40 on unity 5.6, be sure to add the extra framed of delay.

I am downloading the new build and just saw where to toggle pano and stereo on the texture in Unity. Hoping that cures what ails my build. I built both my apps native after pulling my hair out but need to get this done in Unity for my next project.

PrayNoMoreDefects Best-

Jami BeckerInnovation Directornektr, [email protected]

On Tuesday, May 23, 2017 11:44 AM, Vincent Huisman <[email protected]> wrote:

I have used it with Gvr 1.40 on unity 5.6, be sure to add the extra framed of delay.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

i just see this,https://docs.unity3d.com/ScriptReference/VR.VRSettings.LoadDeviceByName.html But there have a problem ,there will be delays.
private void Awake()
{
VRSettings.LoadDeviceByName("Lite");

}

playersetting

[SOLVED]I followed everything how to switch from VR to non VR and it worked but when I want to change from one VR scene to another the second VR scene becomes non-VR I really dont understand why its like that..????

I deployed the Game in my Android device. It only happens in my real device for just brief seconds i see VF but unable to move and then it switches to non-VR.

Thanks a lot @fredsa it worked....

@Rahulxx01 If your second scene tries to load an already loaded VR device name, you might find that your app exits VR:

You can use a String.Compare in your code that switches to VR as shown in the sample code in https://docs.unity3d.com/ScriptReference/XR.XRSettings.LoadDeviceByName.html

    IEnumerator LoadDevice(string newDevice)
    {
        if (String.Compare(XRSettings.loadedDeviceName, newDevice, true) != 0)
        {
            XRSettings.LoadDeviceByName(newDevice);
            yield return null;
            XRSettings.enabled = true;
        }
    }

@Rahulxx01 how did you solve this??

@mari-yam Note that XRSettings.LoadDeviceByName("daydream" or "cardboard") when "daydream" or "cardboard" is already loaded will cause VR mode to exit. Use the String.Compare code avoid this situation. Or, just make sure your game only tries to load the Google VR SDK device once.

Oh thanks it works now
One thing more how did I return back to VR mode to non-VR mode ?

To go back to 2D from VR mode, see SwitchTo2D() here:
https://developers.google.com/vr/develop/unity/guides/hybrid-apps

When I try VR to 2D and click on button which have loadScene console shows error:
"Scene couldn't be loaded it has not been added to the build setting"
But I add all the scenes in build settings :/

When I try VR to 2D and click on button which have loadScene console shows error:
"Scene couldn't be loaded it has not been added to the build setting"
But I add all the scenes in build settings :/

This issue isn't related to the Google VR SDK for Unity.

You can try logging what the scene build count is:
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager-sceneCountInBuildSettings.html

Then, try loading the scene by build index (instead of name):
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html

Switching between VR and non-VR is documented here:
https://github.com/googlevr/gvr-unity-sdk/wiki/Switching-between-VR-and-non-VR-at-runtime

hii
I have a project that makes a VR temple, I found a problem on the button play that happens the bug is VR mode can not load VR scene. this is my code.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.VR;

public class VRToggle : MonoBehaviour
{

public void VRMode()
{
    ToggleVR();
    SceneManager.LoadScene("VRCandi");
}

void ToggleVR()
{

    if (VRSettings.loadedDeviceName == "cardboard")
    {
        StartCoroutine(LoadDevice("None"));
    }
    else
    {
        StartCoroutine(LoadDevice("cardboard"));
    }
}

IEnumerator LoadDevice(string newDevice)
{
    VRSettings.LoadDeviceByName(newDevice);
    yield return null;
    VRSettings.enabled = true;
}

}

can anyone help me??

Was this page helpful?
0 / 5 - 0 ratings