Unity切换VR模式Google Cardboard

时间:2017-06-12 07:30:08

标签: c# unity3d google-vr

我下载了GVR Unity SDK版本1.60.0,我尝试切换用户切换VR模式。我四处寻找切换的方法。看到有人一致地问同样的问题。

http://answers.unity3d.com/questions/1312399/how-to-disable-google-cardboard-from-script.html

我在GVR Unity SDK版本1.60.0中找不到任何文件/脚本名称“GvrViewer”。我还查看提供的演示,选项只有重置和重新输入

代码bellow是旧版本的示例。

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

public class CardBoardToggle : MonoBehaviour {

int vrModeInt;

public void ToggleVRMode(){
    if (PlayerPrefs.GetInt ("Vr Mode") == 1) {
        vrModeInt = 0;
    }
    if (PlayerPrefs.GetInt ("Vr Mode") == 0) {
        vrModeInt = 1;
    }
    PlayerPrefs.SetInt ("Vr Mode", vrModeInt);
}

// Update is called once per frame
void Update () {
    if (PlayerPrefs.GetInt ("Vr Mode") == 1) {
        CardBoard.SDK.VRModeEnabled = true;
    }
    if (PlayerPrefs.GetInt ("Vr Mode") == 0) {
        CardBoard.SDK.VRModeEnabled = false;
    }
}
}

GvrViewer.Instance.VRModeEnabled

0 个答案:

没有答案